Since Google recently announced that Android Studio is the official IDE for Android developement I decided to change my work environment from the Eclipse IDE to Android Studio.
After importing the project to Android Studio I've come across a strange error.
The error says that it can't find two existing R.drawables in an array of R.drawables, the resources are two png pictures.
Here is the syntax of the array:
flag = new int[] {R.drawable.thegodfather,R.drawable.thegeneral,R.drawable.kingofcomedy,
R.drawable.drstrangelove,R.drawable.thebiglebowski}
The two R.drawables that is causing the error are thegodfather and kingofcomedy.
Here is the error messages:
(1)
> Error:(101, 32) error: cannot find symbol variable thegodfather
> Error:(101, 78) error: cannot find symbol variable kingofcomedy
> Note: Some input files use or override a deprecated API.
> Note: Recompile with -Xlint:deprecation for details.
> Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> > Compilation failed; see the compiler error output for details.
(2)
/Users/rawandsultani/Documents/ANDROID/V1/v11/app/src/main/java/com/exple/top100/Top100Activity.java:101: error: cannot find symbol
flag = new int[] {R.drawable.thegodfather,R.drawable.thegeneral,R.drawable.kingofcomedy,
^
symbol: variable thegodfather
location: class drawable
/Users/rawandsultani/Documents/ANDROID/V1/v11/app/src/main/java/com/exple/top100/Top100Activity.java:101: error: cannot find symbol
flag = new int[] {R.drawable.thegodfather,R.drawable.thegeneral,R.drawable.kingofcomedy,
^
symbol: variable kingofcomedy
location: class drawable
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
After countless efforts of cleansings, rebuildings, invertings and restarts the same error still exists. I have checked that the resource is actually there and I have deleted and replaced it just to be sure. It still doesn't work.
What is causing Android Studio to ignore theese two resources?
Here is the beginning of my Android-manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exple.v1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
And here is my Gradle.build :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.exple.v1"
minSdkVersion 11
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
}
Again, I have no clue what is causing this problem. After searching on Stack I've found out that some have had a similiar problem but solved it by cleaning the project or restarting Android Studio which has not worked out for me.
The manifest file and the Gradle.build is for extra information
just in case anyone need a look at it.
Have you verify the do exist in the appropiate folder with the correct name in the Android project?
EDIT:
Have you tried to remove them (Delete) and add them from Android Studio instead of the imported version?
I had the same problem with an existing resource in an imported project from eclipse. In my case the issue was that the resource called loading.png was in fact a .gif, after I fixed the extension the compiler generate the right R.drawable.loading variable.
When Android Studio imported the project it showed this message, but i didnt appear in the sub-sequence compilations
:app:mergeDebugResources
AAPT out(251470765) : No Delegate set : lost message:Done
AAPT err(251470765): libpng error: Not a PNG file
I know it's an old ( very old ) topic, but I just had the same problem and I soon realized that I had placed the resource in a wrong folder ( drawable-v24 instead of drawable ) which was the reason for this resource to be found on other devices. Switch to project instead of android view and check variant specific folders.
Related
Overlay manifest:package attribute declared at AndroidManifest.xml:2:5-37 value=(com.app.app)
has a different value=(com.app.app) declared in main manifest at AndroidManifest.xml:2:5-34
Suggestion: remove the overlay declaration at AndroidManifest.xml and place it in the build.gradle:
flavorName {
applicationId = "com.app.app"
}
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
Manifest merger failed : Overlay manifest:package attribute declared at AndroidManifest.xml:2:5-37 value=(com.app.app)
has a different value=(com.app.app) declared in main manifest at AndroidManifest.xml:2:5-34
Suggestion: remove the overlay declaration at AndroidManifest.xml and place it in the build.gradle:
flavorName {
applicationId = "com.app.app"
}
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 4m 44s
Exception: Gradle task assembleDebug failed with exit code 1
How i can fix this problem?
Try to search them and change your package name in the following locations:
1.) src/profile/AndroidManifest.xml
2.) src/debug/AndroidManifest.xml
3.) src/main/AdroidManifest.xml
4.)
build.gradle .
defaultConfig {
applicationId
5.) MainActivity.java on "package"
If you want to know exactly how to achieve that, take a look at this page for further support.
The best solution to this is by changing the package name in all these 5 files.
1.) android/app/src/debug/AndroidManifest.xml
2.) android/app/src/main/AndroidManifest.xml
3.) android/app/src/profile/AdroidManifest.xml
4.) buildgradle file defaultConfig {applicationId: ""}
5.) MainActivity.java on "package" OR MainActivity.kotlin
After modifying the above files, the Flutter App run seamlessly any issues.
I'm trying to get my app on an android device. When I run
tns run android
I get this error :
/Users/coreelements/Projects/nativescript/myapp/platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:32: AAPT: error: resource
drawable/icon (aka nl.coreelements.myapp:drawable/icon) not found.FAILURE: Build failed with an exception.* What went wrong:
Execution failed for task ':app:processDebugResources'.
Failed to process resources, see aapt output above for details.
I've already tried regenerating the app and splashes :
tns resources generate icons src/images/appicon.png
tns resources generate splashes src/images/appicon.png
What am I missing? I've also tried to buid/run in App Studio.
Just wrapping up the answer from #fransyozef:
App_Resources/Android/src/main/AndroidManifest.xml should point to the right drawable, in this case replacing android:icon="#drawable/icon" with android:icon="#drawable/appicon" solved the issue.
The solution above did not work for me, what did work is change
android:icon="#drawable/icon" to android:icon="#drawable/fileName", so replace /icon with /fileName of the image that is stored there.
I am building an application using flutter and flutterfire (which allows me to use flutter and firebase). With flutterfire I am using firebase_auth. I stopped development for a few weeks and came back to my app not working. I narrowed the issues down to it being my firebase_auth not working. In order to test this, I created a brand new firebase app on Android Studios and tried to connect it to flutterfire. I did all the necessary steps to do this and decided to first test cloud_firestore to see if it would work. It did. As soon as I added the line for firebase_auth in my pubspec.yaml file my app would not even build. The errors I get are below. I have tested previous versions of flutter_fire as well.
D8: Cannot fit requested classes in a single dex file. Try supplying a
main-dex list.
methods: 65968 > 65536
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/5.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/6.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/7.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/8.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/9.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/303.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/304.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/305.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/306.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/307.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/308.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/309.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/310.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/311.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/312.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/313.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/314.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/315.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/316.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/317.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/318.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/319.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/320.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/321.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/322.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/323.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/324.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/325.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/326.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/327.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/328.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/329.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/330.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/331.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/332.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/333.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/334.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/335.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/336.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/337.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/338.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/339.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/340.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/341.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/342.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/343.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/384.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/390.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/396.jar
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at
https://developer.android.com/tools/building/multidex.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
Finished with error: Gradle build failed: 1
The problem looks more Android related and not iOS or Flutter.
If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your module-level build.gradle file, as shown here:
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
}
...
}
More info: https://developer.android.com/studio/build/multidex especially if minSdkVersion < 21
I'm using Dagger 2 in my Android project and I'm having trouble debugging it. I know that the compilation fails because of an error in my dagger 2 setup (had it before) but it's almost impossible to track it down because I don't get a proper error message telling me where the problem lies. All I get are messages that show that the annotation processing failed. Along the lines of:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Error:(14, 28) error: cannot find symbol class BR
Error:(17, 40) error: package com.some.package.databinding does not exist
Error:(17, 51) error: cannot find symbol class DaggerSomeComponent
...
Maybe it's somehow related to the fact that I'm also using databinding!?
I'm using Dagger 2.5, Gradle plugin 2.1.2 and android-apt 1.8.
Thanks for your help!
Java
javac by default will only show up to 100 errors. You are probably over this limit because of databinding reporting an error for each binding class it generates.
Add this to your apps's build.gradle:
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "500"
}
}
Kotlin
You can enable the same javac option when using kapt by adding the following to your build.gradle.
kapt {
javacOptions {
option("-Xmaxerrs", 500)
}
}
This is currently ignored, but will be fixed in Kotlin v1.2.20.
I created an alphabets app. I used 26 audio files. Files extension are .amr. The name of these files are m1.amr to m26.amr.
In emulator everything is working fine but
when I create signed apk, I have a lot of errors
Part of code is given below. I used array for audio files, and keep it in raw directory
private static final int [] media_ids =
{
R.raw.m1,R.raw.m2,R.raw.m3,R.raw.m4..... R.raw.m26
};
and these files code
if(soundboolvalue==true){
try {
mp = MediaPlayer.create(this, R.raw.weldon27); //well done
mp.start();
}catch (Exception e){
e.printStackTrace();
}
at the time of creating signed apk , i got the errors are:-
:app:processReleaseJavaRes UP-TO-DATE
:app:compileReleaseJavaWithJavac
E:\AndroidStudioExeWorkSpace\AlphabetsZone\app\src\main\java\alpha\logintech\alphabetszone\HardModeActivity.java
Error:(40, 46) error: cannot find symbol variable raw
Error:(40, 55) error: cannot find symbol variable raw
Error:(40, 64) error: cannot find symbol variable raw
.
.
Error:(147, 49) error: cannot find symbol variable raw
Note: E:\AndroidStudioExeWorkSpace\AlphabetsZone\app\src\main\java\alpha\logintech\alphabetszone\Main.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Error:Execution failed for task ':app:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
I hope my answer is not late. Recently I was facing exactly same issue, I was trying to make an apk release build but I was getting same error message as you. In other side the app is working perfectly in debug mode.
I figured out that my proguard-rules file is missing some rules because I was enabling the obfuscation in the release mode. you have to double check if you proguard-rules is up to date.
before make any update, try first disable the obfuscation from gradle file or by adding -dontobfuscate to your proguard-rules, if the issue will disappear that means you will have to update you gradle file with your own appropriate rules.