Error:Plugin with id 'kotlin-android' not found. on android studio - java

I get this error when I add this to Android Studio
"Error:Plugin with id 'kotlin-android' not found.".
I am trying to install opencv on my android, but it will not work.
I made a new project in my Android that is empty but works
My build gradle
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
def openCVersionName = "4.5.4"
def openCVersionCode = ((4 * 100 + 5) * 100 + 4) * 10 + 0
println "OpenCV: " +openCVersionName + " " + project.buildscript.sourceFile
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 21
targetSdkVersion 26
versionCode openCVersionCode
versionName openCVersionName
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=c++_shared"
targets "opencv_jni_shared"
}
}
}
buildTypes {
debug {
packagingOptions {
doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
}
}
release {
packagingOptions {
doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['native/libs']
java.srcDirs = ['java/src']
aidl.srcDirs = ['java/src']
res.srcDirs = ['java/res']
manifest.srcFile 'java/AndroidManifest.xml'
}
}
externalNativeBuild {
cmake {
path (project.projectDir.toString() + '/libcxx_helper/CMakeLists.txt')
}
}
}
dependencies {
}

I ran into the same error with Android Studio 2020.3.1 and fixed the error by adding this on top of the skd's build gradle (above 'apply plugin...'):
buildscript {
ext {
kotlinVersion = "1.4.0"
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
repositories {
mavenCentral()
}
}

Related

Implementing hide api for android 30 in project

I decompiled fmradio app for xiaomi. For using hidden api i copyd and replaced android.jar file from https://drive.google.com/drive/folders/185jgOthBI_qXzeS14s795LMGSekSTw5_. I have gradles:
#project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
#module
plugins {
id 'com.android.application'
}
android {
applicationVariants.all { variant ->
//variant.packageApplicationProvider.get().outputDirectory = new File(project.getRootDir().absolutePath + "/" + variant.buildType.name + "/")
variant.outputs.all { output ->
output.outputFileName = "FMRadio" + (variant.buildType.name.toLowerCase().contains("release") ? "" : "-" + variant.buildType.name) + ".apk"
}
}
signingConfigs {
release {
def f = file("../local.properties")
if (f.exists()) {
def props = new Properties()
f.withInputStream { props.load(it) }
storeFile file(props.RELEASE_KEY_PATH)
storePassword props.RELEASE_STORE_PASSWORD
keyAlias props.RELEASE_KEY_ALIAS
keyPassword props.RELEASE_KEY_PASSWORD
} else {
def writer = new FileWriter(f.path)
writer.write("RELEASE_KEY_PATH=\n")
writer.write("RELEASE_KEY_PASSWORD=\n")
writer.write("RELEASE_KEY_ALIAS=\n")
writer.write("RELEASE_STORE_PASSWORD=")
writer.close()
throw new IOException("File $f.name was created. please fill it by values of your release key.")
}
}
}
compileSdkVersion 30
buildToolsVersion "33.0.0"
defaultConfig {
applicationId 'com.miui.fmservice'
minSdkVersion 30
targetSdkVersion 31
versionCode 30
versionName "11"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.fragment:fragment:1.5.3'
}
But after trying to sync project with gradle files i get a large error stack trace,which you can find at https://pastebin.com/PfeN1viv. Help me please why this error happens. May be in android 30 i can't use hidden api? Thanks everybody for any help.

Error while merging dex archives: Program type already present: org.apache.commons.io.Charsets

I'm trying to release APK in react native using ./gradlew bundleRelease I tried
Cleaning gradle
Adding multiDexEnabled true
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:transformDexArchiveWithDexMergerForRelease'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException:
com.android.builder.dexing.DexArchiveMergerException: Error while
merging dex archives: Program type already present:
org.apache.commons.io.Charsets Learn how to resolve the issue at
https://developer.android.com/studio/build/dependencies#duplicate_classes.
This is my build.gradle
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 23
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "11+"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
}
}
app/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js",
enableHermes: false
]
apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.package..."
minSdkVersion 23
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 33
versionName "33.0"
multiDexEnabled true
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
pickFirst '**/libjsc.so'
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
}
def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.android.gms:play-services-gcm:17.0.0"
implementation "com.google.android.gms:play-services-location:17.0.0"
//Add these lines
implementation "com.google.android.gms:play-services-base:17.3.0"
//implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-messaging:20.2.1"
implementation "com.google.firebase:firebase-inappmessaging:19.0.7"
// implementation "com.google.firebase:firebase-inappmessaging-display:19.0.7"
//implementation 'com.android.support:multidex:1.0.3'
//implementation project(':#mauron85_react-native-background-geolocation')
addUnimodulesDependencies()
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply from: file("../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'
Still failing but on my emulator and android device its working fine. Does anyone have this problem too? I really appreciate any idea thanks.

error: undefined reference to 'libiconv_close' in Ndk Android Studio

Iam getting error on setting up my ndk for gstreamer library in android studio.
Below is the error which iam getting-:
cerbero.git/1.16/build/sources/android_universal/armv7/glib-2.56.1/_builddir/../glib/gconvert.c:308: error: undefined reference to 'libiconv_close'
My project level gradle is -:
> buildscript {
> repositories {
> jcenter()
> google()
> }
> dependencies {
> classpath 'com.android.tools.build:gradle:3.5.0'
> } }
>
> allprojects {
> repositories {
> jcenter()
> google()
> } }
and my app.gradle is -:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "org.freedesktop.gstreamer.tutorials.tutorial_2"
minSdkVersion 9
targetSdkVersion 26
ndk {
moduleName "tutorial-2"
abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
externalNativeBuild {
ndkBuild {
path '../../gstreamer-tutorial2/app/src/main/jni/Android.mk'
}
}
}
Refrences which iam using is from-:
Gstreamer examples in Android Studio
Also can anybody help with good references for implemeting gstream library in android studio
Thanks
Try to add libiconv to your Android.mk file
GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_ROOT)/share/gst-android/ndk-build
include $(GSTREAMER_NDK_BUILD_PATH)/plugins.mk
GSTREAMER_PLUGINS := $(GSTREAMER_PLUGINS_CORE) $(GSTREAMER_PLUGINS_NET) x264 openh264 videoparsersbad mulaw
G_IO_MODULES := gnutls
GSTREAMER_EXTRA_LIBS := -liconv #This is what you need
include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer-1.0.mk

generateReleaseBuildConfig errors out in a library

Android Studio project. I have two library modules, neither of them has any Java in it. I'm trying to suppress BuildConfig generation, so that there's no generated Java either. The gradle file for the first one goes:
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 3
targetSdkVersion 26
externalNativeBuild {
ndkBuild {
abiFilters "armeabi", "x86", "x86_64", "armeabi-v7a", "mips", "arm64-v8a"
targets "pad", "gif"
}
}
}
buildTypes {
release {
minifyEnabled false
}
debug {
jniDebuggable true
}
}
externalNativeBuild {
ndkBuild {
path file("src/main/jni/Android.mk")
}
}
}
dependencies {}
afterEvaluate {
generateReleaseBuildConfig.enabled = false
generateDebugBuildConfig.enabled = false
}
For the other:
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 3
targetSdkVersion 26
externalNativeBuild {
ndkBuild {
abiFilters "armeabi", "x86", "x86_64", "armeabi-v7a", "mips", "arm64-v8a"
}
}
}
buildTypes {
release {
minifyEnabled false
}
debug {
jniDebuggable true
}
}
externalNativeBuild {
ndkBuild {
path file("src/main/jni/Android.mk")
}
}
flavorDimensions 'Color'
productFlavors {
Blue {
dimension "Color"
externalNativeBuild {
ndkBuild {
cppFlags "-DBLUE"
}
}
}
Red {
dimension "Color"
externalNativeBuild {
ndkBuild {
cppFlags "-DRED"
}
}
}
}
}
dependencies {
implementation project(':Foo')
}
afterEvaluate {
generateReleaseBuildConfig.enabled = false
generateDebugBuildConfig.enabled = false
}
The first one worked for a while, no problem. The second one, I've created just today, and the Gradle sync on that fails:
A problem occurred configuring project ':LibBar'.
Could not get unknown property 'generateReleaseBuildConfig' for project ':LibBar' of type org.gradle.api.Project.
If I comment that line out, it complains about generateDebugBuildConfig.
The second module depends on the first one, not sure if it matters.
Both have a manifest with nothing but package.
What am I missing? I've tried cleaning the project, invalidating the caches. Gradle is the latest, so is Android Studio (just updated).
The build system decorates the step name with the current build flavor. So it should be instead:
afterEvaluate {
generateBlueReleaseBuildConfig.enabled = false
generateBlueDebugBuildConfig.enabled = false
generateRedReleaseBuildConfig.enabled = false
generateRedDebugBuildConfig.enabled = false
}

Project Gradle sync keeps failing. (Gradle DSL method not found)

beginner android developer so not a lot of experience on how the gradle works, I've tried looking at other examples but I still cant get my problem. Basically, I've just downloaded one of the sample projects from google android developer examples, and cant successfully build the project. I keep getting: Gradle sync failed: Gradle DSL method not found: 'compile()'
The app gradle is:
apply plugin: 'com.android.application'
android {
enforceUniquePackageName = false
compileSdkVersion android_compile_version
buildToolsVersion android_version
defaultConfig {
minSdkVersion android_min_sdk_version
targetSdkVersion android_compile_version
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile "com.android.support:appcompat-v7:${appcompat_library_version}"
compile "com.android.support:support-v4:${support_library_version}"
compile project(':libraries:BaseGameUtils')
compile 'com.google.android.gms:play-services:4.3.23'
}
buildscript {
repositories {
jcenter()
}
}
and as for the project gradle:
// this is the parent build configuration for all the sample projects.
// for more information on gradle build files when used in a multi-project build, see
// http://gradle.org/docs/current/userguide/multi_project_builds.html
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
// allprojects apply to every project
allprojects {
repositories {
jcenter()
}
ext {
android_compile_version = 23
android_version = '23.0.1'
android_min_sdk_version = 9
appcompat_library_version = '23.0.1'
support_library_version = '23.0.1'
gms_library_version = '8.1.0'
}
}

Categories

Resources