Android Resource Linking Failed although i have all the resource files | Kotlin - android

Error Screenshot
Whenever I run the app in emulator it shows the above error. But I have all the resource files.
App Directory
dependencies showed in screenshot.
Other part of the gradle is:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.modshabuisness"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

Did you clean and rebuild project? Would you please check xml selector <?xml version="1.0" encoding="utf-8"?> more than one in your xml file , if had keep it single by removing others.

Related

Crashing app after implementation Sceneform

I'm struggling with a strange issue.
I tried everything to find a solution to why my app crashes.
The reason is "implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.7.0' ".
When I add this implementation I get error:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.myarcore/com.example.myarcore.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class
"com.example.myarcore.MainActivity" on path: DexPathList[[zip file
"/data/app/com.example.myarcore-Aw
This is my app gradle code:
apply plugin: 'com.android.application'
apply plugin: 'com.google.ar.sceneform.plugin'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myarcore"
minSdkVersion 26
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
According to MultiDex documentation if app min sdk is higher than 21 then to enable MultiDex all I need is to put multiDexEnabled true as I did.
SOLVED,
My min SDK was set to 26.
Just add this to your app gradle, even when documentation says that is necessary in min SDK lower than 26.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

OpenCV setup - "plugin with id 'com.android.library' not found"

I'm pretty new to Android development (and gradle). I'm trying to set up the openCV sdk within a new project. The code in the Application/build.gradle file is as follows:
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
The opencv/build.gradle is:
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
And the settings.gradle is:
include 'Application'
include ':opencv'
I get the error in the title when I try to sync the project. Any explanation or help is appreciated. I've looked at a few other similar threads and tried some suggestions in them but nothings worked so far. Thanks!

OpenCV3 error in Camera2Renderer.java [duplicate]

I imported the opencv android library to my android studio and the Camera2Renderer class has a lot of compiler errors because the android.hardware.camera2 classes can't be imported.
I solved the problem. Jim was right, I did not have the correct target API. For the next person who has this problem and finds this thread, the solution is that you have to make sure that the build.gradle files for your project and your OpenCV match.
I am working with openCVLibrary3.2.0 and trying to run its sample and faced same issue but I changed gradle files for both mysampleApp and openCVLibrary320 module as below
This is my app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "org.opencv.face"
minSdkVersion 9
targetSdkVersion 21
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_5
targetCompatibility JavaVersion.VERSION_1_5
}
ndk {
moduleName "native_sample"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
}
dependencies {
compile project(path: ':openCVLibrary320')
}
and this my OpenCV library module build.gradle file
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
Note:
things to notice are that compileSdkVersion, buildToolsVersion, minSdkVersion, and targetSdkVersion these must be same for all gradle files
I changed the compileSdkVersion from 14 to 23
and buildToolsVersion to "23.0.2"
this solved the camera2 import related issue
I am working on openCVLibrary330 trying to run its sample and faced same issue but i changed gradle files for openCVLibrary330 module as below
This is my app build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "26.0.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
I had the same problem. But, as many people have suggested I didn't had to change the gradle files to match exactly the same. I changed my compileSdkVersion and buildToolsVersion to the same on both gradle files, the rest are different. Its working fine now.

Gradle: passing parameters to `apply from: <file>`

I'd like to put some common boilerplate gradle script code into shared .gradle file. Then, I can reuse it using apply from: statement.
The question is whether it's possible to pass parameters to applied script?
For example, I'd like to reuse the following boiler plate:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'org.robolectric'
configurations {
apt
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
The problem is here: apply plugin: 'com.android.application'. I'd like to reuse this code either for application projects or android library projects. So I need some parameter in order to decide which plugin to apply:
// assuming <isApplicationProject> - is a script parameter
if (isApplicationProject) {
apply plugin: 'com.android.application'
} else {
apply plugin: 'com.android.library'
}
Of course, I can just define some project-level property in this particular case, but I'd like to know whether it's possible to pass parameters upon script invocation
apply from: is line include<> you cannot pass parameters.
however it does run on the same context and therefor on the same project, so you can do something of:ext.isUsingApp=true; apply from: 'xxx'
if that's the only difference i would advise you to do something of the following:
myinclude.gradle:
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'org.robolectric'
configurations {
apt
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
then in your build.gradle app:
apply plugin: 'com.android.application'
apply from: '../includes/myinclude.gradle'
then in your libs build.gradle:
apply plugin: 'com.android.library'
apply from: '../includes/myinclude.gradle'
for a simple Boolean no need to create parameter.

cannot resolve dependencies in Android Studio

Im really stuck whit this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.example.testing"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':External-Module')
}
I dont know what to do... I cant build project and use dependencies from External module.
the error is:
Error:(7, 47) error: package com.example.android.transfer does not exist
Error:(19, 9) error: cannot find symbol class ClientData
Error:(19, 25) error: cannot find symbol variable ClientData
Error:Execution failed for task ':Testing:compileDebugJava'.
but inside the IDE all is well and I can see the module
Here is also the External Module
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.example.externalmodule"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
}
Your "External-Module" is an Android library, so according to the Gradle+Android documentation instead of
apply plugin: 'com.android.application'
it should be
apply plugin: 'com.android.library'
// Old version of the plugin
// apply plugin: 'android-library'
Also, make sure the imports in your app matches the package you are overriding in your library build script. Looks like the app is not founding com.example.android.transfer but the library package really is com.example.externalmodule

Categories

Resources