Build android app from command line without gradle, I tried the following article and working for simple Android App.
How to make Android apps without IDE from command line
But failed while trying with AppCompat layout, tried the following command line but still no luck
aapt package --auto-add-overlay -f -m -J $SRC_BASE/build/gen/java -M $SRC_BASE/src/AndroidManifest.xml -S $SRC_BASE/src/res -S /path/to/appcompat/v1.2.0/res -I /android-home/platforms/android-23/android.jar
ERROR: (using android-23)
/path/to/appcompat/v1.2.0/res/values-v24/values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
/path/to/appcompat/v1.2.0/res/values-v24/values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
/path/to/appcompat/v1.2.0/res/values-v26/values-v26.xml:15: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
even I tried with android-30.
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:9: error: No resource identifier found for attribute 'layout_constraintBottom_toTopOf' in package 'my.pkg.tst'
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:9: error: No resource identifier found for attribute 'layout_constraintLeft_toLeftOf' in package 'my.pkg.tst'
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:9: error: No resource identifier found for attribute 'layout_constraintRight_toRightOf' in package 'my.pkg.tst'
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:9: error: No resource identifier found for attribute 'layout_constraintTop_toTopOf' in package 'my.pkg.tst'
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:20: error: No resource identifier found for attribute 'layout_constraintTop_toBottomOf' in package 'my.pkg.tst'
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:20: error: No resource identifier found for attribute 'layout_constraintBottom_toTopOf' in package 'my.pkg.tst'
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:20: error: No resource identifier found for attribute 'layout_constraintLeft_toLeftOf' in package 'my.pkg.tst'
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:20: error: No resource identifier found for attribute 'layout_constraintRight_toRightOf' in package 'my.pkg.tst'
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:31: error: No resource identifier found for attribute 'layout_constraintTop_toBottomOf' in package 'my.pkg.tst'
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:31: error: No resource identifier found for attribute 'layout_constraintBottom_toBottomOf' in package 'my.pkg.tst'
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:31: error: No resource identifier found for attribute 'layout_constraintLeft_toLeftOf' in package 'my.pkg.tst'
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:31: error: No resource identifier found for attribute 'layout_constraintRight_toRightOf' in package 'my.pkg.tst'
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:9: error: Error: No resource found that matches the given name (at 'layout_constraintBottom_toTopOf' with value '#id/tv2').
${PROJECT_BASE_DIR}/src/res/layout/activity_main.xml:20: error: Error: No resource found that matches the given name (at 'layout_constraintBottom_toTopOf' with value '#id/tv3').
/path/to/appcompat/v1.2.0/res/color/abc_btn_colored_borderless_text_material.xml:20: error: No resource identifier found for attribute 'alpha' in package 'my.pkg.tst'
/path/to/appcompat/v1.2.0/res/color/abc_btn_colored_text_material.xml:20: error: No resource identifier found for attribute 'alpha' in package 'my.pkg.tst'
/path/to/appcompat/v1.2.0/res/color/abc_tint_btn_checkable.xml:19: error: No resource identifier found for attribute 'alpha' in package 'my.pkg.tst'
/path/to/appcompat/v1.2.0/res/color/abc_tint_default.xml:19: error: No resource identifier found for attribute 'alpha' in package 'my.pkg.tst'
/path/to/appcompat/v1.2.0/res/color/abc_tint_edittext.xml:19: error: No resource identifier found for attribute 'alpha' in package 'my.pkg.tst'
/path/to/appcompat/v1.2.0/res/color/abc_tint_seek_thumb.xml:19: error: No resource identifier found for attribute 'alpha' in package 'my.pkg.tst'
/path/to/appcompat/v1.2.0/res/color/abc_tint_spinner.xml:19: error: No resource identifier found for attribute 'alpha' in package 'my.pkg.tst'
/path/to/appcompat/v1.2.0/res/color/abc_tint_switch_track.xml:19: error: No resource identifier found for attribute 'alpha' in package 'my.pkg.tst'
/path/to/appcompat/v1.2.0/res/color/abc_tint_switch_track.xml:20: error: No resource identifier found for attribute 'alpha' in package 'my.pkg.tst'
/path/to/appcompat/v1.2.0/res/color/abc_tint_switch_track.xml:21: error: No resource identifier found for attribute 'alpha' in package 'my.pkg.tst'
Anybody have success with AppCompat and other libraries without gradle, only using pure java, and android sdk tools ? (ant is also fine.)
Build the android app without gradle for simple app without app-compat. The following code is working fine for simple android app.(reference for if anyone interested.)
mkdir -p ${PROJECT_BASE_DIR}/build/gen/java
aapt package -f -m -J ${PROJECT_BASE_DIR}/build/gen/java -M ${PROJECT_BASE_DIR}/src/AndroidManifest.xml -S ${PROJECT_BASE_DIR}/src/res -I ${ANDROID_SDK_HOME}/platforms/android-30/android.jar
mkdir -p ${PROJECT_BASE_DIR}/build/classes
javac -d ${PROJECT_BASE_DIR}/build/classes -source 1.7 -target 1.7 -classpath ${PROJECT_BASE_DIR}/src/java:${PROJECT_BASE_DIR}/build/gen/java -bootclasspath ${ANDROID_SDK_HOME}/platforms/android-30/android.jar ${PROJECT_BASE_DIR}/src/java/jj/android/clb/MainClass.java
dx --dex --output=${PROJECT_BASE_DIR}/build/classes.dex ${PROJECT_BASE_DIR}/build/classes
aapt package -f -m -F ${PROJECT_BASE_DIR}/build/app.unaligned.apk -M ${PROJECT_BASE_DIR}/src/AndroidManifest.xml -S ${PROJECT_BASE_DIR}/src/res -I ${ANDROID_SDK_HOME}/platforms/android-30/android.jar
cd ${PROJECT_BASE_DIR}/build
aapt add ${PROJECT_BASE_DIR}/build/app.unaligned.apk classes.dex
'classes.dex'...
cd ..
zipalign -f 4 build/app.unaligned.apk build/app.aligned.apk
apksigner sign --ks Andorid-KeyStore.jks --in build/app.aligned.apk --out build/app.sign.apk
I'm trying to build my first android project from Unity..
CommandInvokationFailure: Failed to re-package resources.
..\tools_r25.2.3-windows\build-tools\27.0.3\aapt.exe package
--auto-add-overlay -v -f -m -J "gen" -M "AndroidManifest.xml" -S "res" -I "../tools_r25.2.3-windows\platforms\android-23\android.jar" -F bin/resources.ap_
stderr[ AndroidManifest.xml:4: error: Error: No resource found that
matches the given name (at 'theme' with value
'#style/UnityThemeSelector').
AndroidManifest.xml:4: error: Error: No resource found that matches
the given name (at 'icon' with value '#drawable/app_icon').
AndroidManifest.xml:4: error: Error: No resource found that matches
the given name (at 'label' with value '#string/app_name').
AndroidManifest.xml:4: error: Error: No resource found that matches
the given name (at 'banner' with value '#drawable/app_banner').
AndroidManifest.xml:5: error: Error: No resource found that matches
the given name (at 'label' with value '#string/app_name').
] stdout[ Configurations: (default)
Files: AndroidManifest.xml
Src: () AndroidManifest.xml
I'm aware of the fact that I'm not the first to have a similar error, yet I've not bean able to fix this yet and would appreciate any help.
Thanks
This question already has answers here:
Can the Android drawable directory contain subdirectories?
(22 answers)
Closed 8 years ago.
Is it possible to create subfolder structures inside main res folders, especially in drawable folder using Gradle?
I have attempted this so far
sourceSets {
main {
res.srcDirs = [
"/src/main/res/drawable-xhdpi/actionbar_items",
"/src/main/res/drawable-xhdpi/intro",
"/src/main/res/drawable-xhdpi/loading_screen",
"/src/main/res/drawable-xhdpi",
"/src/main/res",
]
}
}
When I rebuild the project however I get this Gradle build error message something like this:
Error:(39, 23) No resource found that matches the given name (at 'icon' with value '#drawable/app_icon').
Error:(40, 24) No resource found that matches the given name (at 'label' with value '#string/app_name').
Error:(42, 24) No resource found that matches the given name (at 'theme' with value '#style/AppTheme').
Error:(45, 28) No resource found that matches the given name (at 'label' with value '#string/app_name').
Error:(50, 28) No resource found that matches the given name (at 'label' with value '#string/app_name').
Error:(55, 28) No resource found that matches the given name (at 'label' with value '#string/app_name').
Error:(73, 28) No resource found that matches the given name (at 'label' with value '#string/app_name').
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/adrian/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W/aapt package -f --no-crunch -I /Users/adrian/adt-bundle-mac-x86_64-20140702/sdk/platforms/android-19/android.jar -M /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml -S /Users/adrian/Development/alstom_framework/app/build/intermediates/res/debug -A /Users/adrian/Development/alstom_framework/app/build/intermediates/assets/debug -m -J /Users/adrian/Development/alstom_framework/app/build/generated/source/r/debug -F /Users/adrian/Development/alstom_framework/app/build/intermediates/libs/app-debug.ap_ --debug-mode --custom-package com.hiddenltd.framework -0 apk --output-text-symbols /Users/adrian/Development/alstom_framework/app/build/intermediates/symbols/debug
Error Code:
1
Output:
/Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:35: error: Error: No resource found that matches the given name (at 'icon' with value '#drawable/app_icon').
/Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:35: error: Error: No resource found that matches the given name (at 'label' with value '#string/app_name').
/Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:35: error: Error: No resource found that matches the given name (at 'theme' with value '#style/AppTheme').
/Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:43: error: Error: No resource found that matches the given name (at 'label' with value '#string/app_name').
/Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:48: error: Error: No resource found that matches the given name (at 'label' with value '#string/app_name').
/Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:52: error: Error: No resource found that matches the given name (at 'label' with value '#string/app_name').
/Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:70: error: Error: No resource found that matches the given name (at 'label' with value '#string/app_name').
This means to me that the gradle sees only the res folders specified by me in app.gradle file ? Therefore I added the rest of it to the app.gradle and same error occurs...
Can anyone help please ....
No, Android expects all the files to be in a single directory, and does not allow subfolders to be used.
Most apps use a naming convention in place of subfolders, so in your example you might end up with a list of files:
intro_welcome.png
intro_background.png
loading_splashscreen.png
actionbar_delete.png
I can use apktool to decode apk then build again for my normal android project.
But when I tried same thing with the project that depends on the library project (appcompat), it failed with following errors.
Do I need to build with library project and if so, how can I specify that?
$ apktool build apkdecode repack.apk
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...
/<currentdir>/apkdecode/res/values/styles.xml:59: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.
/<currentdir>/apkdecode/res/values/styles.xml:99: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.
/<currentdir>/apkdecode/res/values/styles.xml:146: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.
/<currentdir>/apkdecode/res/values/styles.xml:176: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.
/<currentdir>/apkdecode/res/values/styles.xml:192: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base.DropDownItem'.
/<currentdir>/apkdecode/res/values/styles.xml:218: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.
/<currentdir>/apkdecode/res/values/styles.xml:225: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Light.Base'.
/<currentdir>/apkdecode/res/values/styles.xml:242: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Base'.
/<currentdir>/apkdecode/res/values/styles.xml:275: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.
/<currentdir>/apkdecode/res/values-v14/styles.xml:50: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.
/<currentdir>/apkdecode/res/values/styles.xml:467: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Base'.
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 8, --target-sdk-version, 11, -F, /var/folders/6l/q11hqqj57rs0lgxcx1njdlxc0000gn/T/APKTOOL2534308390228031373.tmp, -0, arsc, -I, /<toolpath>/apktool/framework/1.apk, -S, /<currentdir>/apkdecode/res, -M, /<currentdir>/apkdecode/AndroidManifest.xml]
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:358)
at brut.androlib.Androlib.buildResources(Androlib.java:283)
at brut.androlib.Androlib.build(Androlib.java:206)
at brut.androlib.Androlib.build(Androlib.java:176)
at brut.apktool.Main.cmdBuild(Main.java:228)
at brut.apktool.Main.main(Main.java:79)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 8, --target-sdk-version, 11, -F, /var/folders/6l/q11hqqj57rs0lgxcx1njdlxc0000gn/T/APKTOOL2534308390228031373.tmp, -0, arsc, -I, /<toolpath>/apktool/framework/1.apk, -S, /<currentdir>/apkdecode/res, -M, /<currentdir>/apkdecode/AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:357)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:336)
... 5 more
Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 8, --target-sdk-version, 11, -F, /var/folders/6l/q11hqqj57rs0lgxcx1njdlxc0000gn/T/APKTOOL2534308390228031373.tmp, -0, arsc, -I, /<toolpath>/apktool/framework/1.apk, -S, /<currentdir>/apkdecode/res, -M, /<currentdir>/apkdecode/AndroidManifest.xml]
at brut.util.OS.exec(OS.java:89)
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:355)
... 6 more
It's a problem of apktool v1 (1.5.3).
There are several ways to solve it.
1. Edit styles.xml.
Add the empty 'parent' attribute to the tags on the error lines. For example:
Before
59: <style name="Widget.AppCompat.Base.ActionBar">
After
59: <style name="Widget.AppCompat.Base.ActionBar" parent="">
Then build the project. In this way you need to edit xml every time you decode apk.
2. Edit apktool sources and rebuild it.
You have to edit method 'serializeToResValuesXml' in the file 'android-apktool/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResStyleValue.java':
Before
if (!mParent.isNull()) {
serializer.attribute(null, "parent", mParent.encodeAsResXmlAttr());
}
After
if (!mParent.isNull()) {
serializer.attribute(null, "parent", mParent.encodeAsResXmlAttr());
} else if (res.getResSpec().getName().indexOf('.') != -1) {
serializer.attribute(null, "parent", "");
}
3. Just use apktool v2 :)
I have saved my images in res/drawable folder but still it is giving me this error on console
[2012-04-28 18:36:46 - Local] libpng error: Not a PNG file
[2012-04-28 18:36:46 - Local] ERROR: Failure processing PNG image D:\Android2_worksapce\Local\res\drawable-ldpi\ic_launcher.png
[2012-04-28 18:36:46 - Local] libpng error: Not a PNG file
[2012-04-28 18:36:46 - Local] ERROR: Failure processing PNG image D:\Android2_worksapce\Local\res\drawable-mdpi\ic_launcher.png
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\aboutus.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/about').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\autofare.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/auto').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\busroutes.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/bus').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\busroutes.xml:63: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/right').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\busroutes.xml:72: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/cancel').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\firstscreenactivity.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/mumbai1').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\listviewofwesternavailabletrains.xml:8: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/cell3').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\main.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/first').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\mumbaihelpline.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/helpline').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\selectambulance.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/ambu').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\selectedwesterntraindetails.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/list6').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\selecthospital.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/hospital').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\selectservicelistview.xml:7: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/cell1').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\selecttrainline.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/curv').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\taxifare.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/taxi').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\westernavailabletrains.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/list5').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\westernavailabletrains.xml:18: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/cell3').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\youareatcentral.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/local').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\youareatcentral.xml:70: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/right').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\youareatcentral.xml:79: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/cancel').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\youareatharbour.xml:2: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/local').
[2012-04-28 18:36:46 - Local] D:\Android2_worksapce\Local\res\layout\youareatharbour.xml:69: error: Error: No resource found that matches the given name (at 'background' with value '#drawable/right').
I have saved the images (in png format) in resources, but it is giving me an error stating that it's not png file. Can anyone help me out?
One Easy but time consuming solution...
Try opening your png in mspaint and do save As. this issue will resolve..
i dont know why we need to do this.. but somehow its working for me...
Check this link for reference
Android does support 24-bit and 32-bit,
but it has some problem with ADOBE PHOTOSHOP's PNG files.
So the solution is to open in MS Paint and save again as Kalpesh Patel said.
Hope this may help you
This is because of any jpg file is mistakenly converted to a png file. If you have added any images in drawable folder (asset folder) then make sure that all images extension should be png means do not change extension jpg to png. If you want to convert jpg to png then use online tool or editor to convert.
The issue is if image is not converted properly to PNG then when you run then it will give this error.
Solution: 1st do you added any images recently in a drawable folder? if yes then check all images extension should proper (i mean do not forcefully add png extension).
or
2nd if you not sure which image extension is not proper then you should have to edit all png images in the editor or online tool and save again into png file by this issue will get solved for sure.
I have spend 3 hours on this to figure out and i come up with this solution. It was my mistake i have edited jpg image to png but it is not properly converted to png so thats why it was giving me error. After i pick that image and properly converted to png file then it work for me!