from this link i had use multi language support in my Android Project, Yesterday i decided to switch to Intellij Idea gradle, when i remove value files in different language, app run normally with default language
but with multi string value file get this error
Error:Gradle: Execution failed for task ':...:processDebugResources'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/.../sdk/build-tools/android-4.4.2/aapt package -f --no-crunch -I
/home/.../sdk/platforms/android-19/android.jar -M
/home/.../.../build/manifests/debug/AndroidManifest.xml -S
/home/.../.../build/res/all/debug -A
/home/.../.../build/assets/debug -m -J /home/.../.../build/source/r/debug -F
/home/.../.../build/libs/...-debug.ap_ --debug-mode --custom-package ... --output-text-symbols /home/.../build/symbols/debug
Error Code:
1
Output:
/home/.../build/res/all/debug/values-Ar/values.xml: error: Duplicate file.
/home/.../build/res/all/debug/values/values.xml: Original is here.
Your problem seems to be with naming conventions.
The main problem with the structure you're using is that you used a capital letter.
In android file structure in res folder should always be in lowercase.
instead of
values-Ar
you should use
values-ar
for your values folder if you want an arabic locale to find your strings,values ...
Related
I've been trying to use aapt2.exe to build Android assets, but it is not working.
The command I'm using is:
&"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\aapt2.exe" link --manifest AndroidManifest.xml --proto-format --output-to-dir --custom-package com.infinitespacestudios.legacyinstalltimeexample.assetsfeature -A Assets -o obj\Debug\netstandard2.0\feature
However, it generates the error:
error: failed to write assets/Hello.json to archive: M├ñ├ñritetty├ñ tiedostoa ei l├Âydy. (2).
The end of the error message is garbled Finnish, which says "The specified file is not found."
It generates this error regardless of the directory specified with -A. Could it possibly be because I have Finnish operation system?
I tried also running the executable as an administrator, but it did not help.
We have a great build system, so we're not looking to use gradle. Right now, we use appt to build an APK and it works great and the APK runs well. I see that aapt2 is the future, though, and so we'd like to move to it before we're forced to.
What we currently do:
We have a simple icon in res/mipmap/our_icon.png
We have our ./AndroidManifest.xml file
We have our libMyApp.so stored in apk/lib/armeabi-v7a/libMyApp.so
We build using the following command: aapt package -f -M AndroidManifest.xml -S ./res -I /opt/android-sdk/platforms/android-28/android.jar -F my app-unsigned.apk apk/
We then zipalign and sign using apksigner and the app loads just fine. As you can see, all very simple and gives us just what we need.
I've tried the following with aapt2, but of course it is incorrect:
aapt2 compile ./res/mipmap/our_icon.png -o ./compiled
aapt2 link -v -I /opt/android-sdk/platforms/android-28/android.jar -I compiled/mipmap_our_icon.png.flat --manifest AndroidManifest.xml -o MyApp-unsigned.apk
note: including compiled/minmap_our_icon.png.flat.
error: failed to open APK: Invalid file.
You're trying to provide the resources the way you'd provide an APK (e.g. android.jar):
-I compiled/mipmap_our_icon.png.flat
To pass compiled resources use the -R flag (per each resource or use the wildcard * if you want to pass the whole directory, e.g. compiled/*).
You can find more info on differences between aapt and aapt2 in my old answer here.
As you can see from the project below, I want to know how to generate the java file in the gen folder:
Create R.java
In order for the application source code to be able to access the resources within the res/ directory, a class called R.java (for Resources) is created.
Use the Android Asset Packaging Tool (aapt) to create the R.java file:
ANDROID_HOME/platform-tools/aapt
package
-v
-f
-m
-S DEV_HOME/res
-J DEV_HOME/src
-M DEV_HOME/AndroidManifest.xml
-I ANDROID_HOME/platforms/android-7/android.jar
Building Android programs on the command line
I was trying to compile Android project using command line in Windows. When I use aapt to generate R file, it comes out an error as below:
D:\SampleProject\MyApplication>aapt package -f -m -J ./gen -S ./app/src/main/res
-I "D:\ProgramInstall\Android\Android SDK\platforms\android-21\android.jar" -M
./app/src/main/AndroidManifest.xml
.\app\src\main\res\values\styles.xml:4: error: Error retrieving parent for item:
No resource found that matches the given name 'Theme.AppCompat.Light.DarkAction
Bar'.
I've found that the Theme.Appcompact.Light.DarkActionBar is related to the APPcompat_v7 floder while the floder is under in the libs floder, How can I let the complier know where to find the lib it need?
I know its too late or you may have already found the answer also but still posting:
D:\SampleProject\MyApplication>aapt package **--auto-add-overlay** -f -m -J ./gen -S ./app/src/main/res **-S "path_to_prebuilts\prebuilts\devtools\extras\android\support\v7\appcompat\res\"** -I "D:\ProgramInstall\Android\Android SDK\platforms\android-21\android.jar" -M ./app/src/main/AndroidManifest.xml
I am trying to build R.java by using aapt from the command line. I am specifying multiple -S directories because I have multiple res directories. I am building by using:
aapt package \
-M AndroidManifest.xml \
-m -J gen \
-S src/com/example/res \
-S src/com/example/ui/res
Unfortunately, I am getting the following error:
src/com/example/ui/res/values/strings.xml:2: error: Resource at app1_name appears in overlay but not in the base package; use <add-resource> to add.
Currently, src/com/example/ui/res/values/strings.xml contains the following:
<resources>
<string name="app1_name">MyAppName</string>
</resources>
I would prefer not to have to change this to:
<resources>
<add-resource type="string" name="app1_name">MyAppName</add-resource>
</resources>
(This was suggested on https://groups.google.com/forum/?fromgroups#!topic/android-porting/bYfeLEjERjg, though it does not even seem to solve my problem.)
Am I misguided in my expectation of how the -S argument should work?
The only workaround I can think of is to symlink all of my -S directories as subdirectories of the root res directory and to specify res as the only -S directory.
I believe the solution is to use the --auto-add-overlay flag. I discovered this by running the default Ant build script with -v for verbose mode.