I once asked a similar question when I faced the same problem here in which the Linker was doing its job a bit too efficiently.
Then I found that it was an issue posted on the MAUI repo on GitHub here.
Jonathan Peppers on the GitHub issue suggested that we should add the following to the csproj
<EmbeddedResource Include="ILLink.Descriptors.xml">
<LogicalName>ILLink.Descriptors.xml</LogicalName>
</EmbeddedResource>
and create an xml file with the following
<linker>
<assembly fullname="Mono.Android">
<type fullname="Android.Runtime.InputStreamAdapter" preserve="methods" />
<type fullname="Android.Runtime.InputStreamInvoker" preserve="methods" />
</assembly>
</linker>
I even deleted the bin, obj folders, cleaned, rebuilt the project with no luck.
So I then tried <AndroidLinkMode>None</AndroidLinkMode> and even that wasn't working.
When opening the app or starting the app in debug, it crashes on the splash screen, producing the following error message MSB3073: The command ""C:\Program Files (x86)\Android\android-sdk\platform-tools\adb" -s emulator-5554 uninstall -k "com.companyname.medbaseapplication"" exited with code 1. 0
How do I solve this problem?
Edit 1: Here is the build output as requested in the comments
https://drive.google.com/file/d/1WHbzMHmqLGFE_3Ne3lW5jwp09ZRYAAWk/view?usp=sharing
Related
as part of a custom Android build chain, I am calling "aapt2 link" in order to link the files generated by a previous call to "aapt2 compile" together. This works fine on Mac, but on Windows it fails with the following error:
failed to open file: The device does not recognize the command.
I'm using the same SDK versions, and the error happens on multiple systems, including my own those of users of our build chain.
I'm calling rapt as follows:
C:\Users\mh\AppData\Local\Android\sdk\build-tools\33.0.1\aapt2.exe
link
-v
-o c:\obj\destination.apk
--manifest c:\Obj\manifest.xml
--java c:\Obj\java
-I C:\obj\android.jar
--proto-format
--min-sdk-version 26
--target-sdk-version 26
#c:\Obj\Aapt2LinkFiles.txt
(paths shortened for clarity here). All files listed in c:\Obj\Aapt2LinkFiles.txt exist, and aapt prints them all out, before emitting the error.
Does anyone have an idea what I could be missing?
As a side question: Is there a way to see, in Android Studio, how and with what parameters aapt2 is called as part of the normal automated build process? Because builds in Android Studio work fine (but I seem to not be able tom find any lace where there is a full build log, in the way that other IDEs such as Xcode or Visual Studio provide a textual overview of what actual tools get executed and with what parameters, as you build.
Thanx!
Update full command line for repro:
C:> C:\Users\mh\AppData\Local\Android\sdk\build-tools\33.0.1\aapt2.exe link -v -o c:\Obj\ForAAB.apk --manifest c:\Obj\m.xml --java c:\Obj\java -I C:\obj\a.jar --proto-format --min-sdk-version 26 --target-sdk-version 26 #c:\Obj\files.txt
Output
note: including C:\obj\a.jar.
note: linking package 'org.me.testapt2' using package ID 7f.
c:\Obj\res-aapt2\drawable-hdpi_icon.png.flat
c:\Obj\res-aapt2\drawable-ldpi_icon.png.flat
c:\Obj\res-aapt2\drawable-mdpi_icon.png.flat
c:\Obj\res-aapt2\drawable-xhdpi_icon.png.flat
c:\Obj\res-aapt2\drawable_icon.png.flat
c:\Obj\res-aapt2\layout_main.xml.flat: error: failed to open file: The device does not recognize the command. (22).
error: failed parsing input.
files can be found at https://www.dropbox.com/s/zuuopmhyzkd271u/Obj.zip?dl=0, unzip to C:\Obj
I'm quite new to Android native development and lately experimenting with building directly from CLI without Android Studio (really don't like the IDE and find Gradle overly complex, although I can't get my toolchain running yet...)
Using guidance from around the web, particularly this, I have a extremely basic app which successfully builds to a signed and aligned APK (as far as I can tell). I am building against platform 14 with Java 1.8 and I observed no changes when altering this configuration.
I've put the app source on GitHub for reference for this question. It's one activity with one layout.
When it comes to adb install (or manually install from the device), installation always fails with INSTALL_FAILED_INVALID_APK... Package /data/app/net.ilmiont.helloworld-...==/base.apk code is missing (... is some long ID by appearances).
Logcat
Running adb logcat during the installation attempt, I get this:
11-16 10:34:52.729 24742 7402 I Finsky : [9791] com.google.android.finsky.verifier.impl.ea.a(82): Skipping verification. Disabled by user setting
11-16 10:34:52.729 24742 7402 I Finsky : [9791] com.google.android.finsky.verifier.impl.ea.a(43): Skipping anti malware verification due to pre-check failure
11-16 10:34:52.730 24742 24742 I Finsky : [2] com.google.android.finsky.verifier.impl.fs.c(164): Verifying id=132, result=1
11-16 10:34:52.735 24742 24742 I Finsky : [2] com.google.android.finsky.verifier.impl.fs.c(177): Verification complete: id=132, package_name=net.ilmiont.helloworld
11-16 10:34:52.752 1856 27782 E : Couldn't opendir /data/data/net.ilmiont.helloworld: No such file or directory
11-16 10:34:52.753 1856 27782 E installd: Failed to delete /data/data/net.ilmiont.helloworld: No such file or directory
11-16 10:34:52.753 1856 27782 E : Couldn't opendir /data/user_de/0/net.ilmiont.helloworld: No such file or directory
11-16 10:34:52.753 1856 27782 E installd: Failed to delete /data/user_de/0/net.ilmiont.helloworld: No such file or directory
11-16 10:34:52.754 2198 2398 W PackageManager: com.android.server.pm.Installer$InstallerException: android.os.ServiceSpecificException: Failed to delete /data/user_de/0/net.ilmiont.helloworld (code 2)
11-16 10:34:52.756 2198 2398 W PackageManager: Package couldn't be installed in /data/app/net.ilmiont.helloworld-pbDVHiVe6mEghhiOqRUNjg==
11-16 10:34:52.756 2198 2398 W PackageManager: com.android.server.pm.PackageManagerException: Package /data/app/net.ilmiont.helloworld-pbDVHiVe6mEghhiOqRUNjg==/base.apk code is missing
I do not understand why it is trying to open/delete these directories when the app is just getting installed (and has not ever successfully installed) --- I don't know enough about Android internals, but from that trace it does look like the deletion is the problem.
I've looked over my source multiple times and just can't see what I'm missing. The manifest looks OK, the layout looks OK, the Java is all of two lines. So what am I missing? It must be something glaringly obvious.
The device
This may be relevant, so here are all the details.
Nokia 6 (original one) running unrooted Android 8.1.
I opened Android Studio, created the default boilerplate app and hit "Run", and it built and deployed successfully, so clearly there is something wrong with my app/build toolchain which is making this break, and I've out of ideas of where to look.
The build script (excerpts, it does build but will not deploy)
aapt package -v -f -m -J $PROJECT_SOURCE -M $ANDROID_MANIFEST -S $ANDROID_RESOURCES -I $ANDROID_SDK/platforms/android-$ANDROID_API/android.jar;
javac -d $JAVA_COMPILE_DESTINATION -source $JAVA_VERSION -target $JAVA_VERSION_TARGET -classpath "$PROJECT_SOURCE$JAVA_CLASSPATH_LIBS" -bootclasspath $ANDROID_SDK/platforms/android-$ANDROID_API/android.jar $PROJECT_SOURCE/$PROJECT_PACKAGE_SOURCE/*.java;
dx --dex --output=$DX_COMPILE_DESTINATION $JAVA_COMPILE_DESTINATION;
aapt package -f -m -F $APP_APK_UNALIGNED -M $ANDROID_MANIFEST -S $ANDROID_RESOURCES -I $ANDROID_SDK/platforms/android-$ANDROID_API/android.jar;
aapt add $APP_APK_UNALIGNED $DX_COMPILE_DESTINATION;
zipalign -f 4 $APP_APK_UNALIGNED $APP_APK;
apksigner sign --ks /home/jh_walker/.keystore $APP_APK;
Keystore
keytool -genkeypair -validity 365 -keystore $KEYSTORE -alias $KEYSTORE_ALIAS -sigalg SHA1withDSA -keyalg DSA -keysize 1024
What I've tried
Java 1.7/1.8
Compiling against different Android platforms (21/28)
Including additional assets (didn't have icons originally)
Setting use-sdk in the manifest (no impact)
What am I missing?
I got there.
aapt inspect app.apk
And immediately I noticed in the APK, was ./bin/classes.dex, and none of the other files had that ./ prefix.
Digging deeper, and I saw in my build script I was compiling DEX to ./bin/classes.dex, and then adding that path to my APK. But it appears something about that path wasn't liked by aapt (although it's entirely valid for where I was running it from), and it didn't properly add the file --- it seems just some empty ./bin/classes.dex it made up.
(Yes that's a kinda pathetic explanation, and I'll investigate properly later!)
Anyway, it seems you have to add from your current directory: classes.dex. Maybe this is obvious to someone more familiar with the tools.
Anyway,
cp ./bin/classes.dex . && aapt add app.apk.unaligned classes.dex works, but aapt add app.apk.unaligned ./bin/classes.dex does not .
If this somehow happens to you when you want to install a debug (gradle installDebug) version of your App in your device, check that versionCode and versionName are not changed from the last release published to the Play Store.
I was also getting the base.apk code is missing error message when attempting to install the apk on my device. In my case, I had recently upgraded Gradle and Android Gradle tools (naively because Studio recommended it).... So, downgrading to the previous gradle and tools version fixed it for me.
Downgrading can be done by editing the version numbers in 2 locations: android/build.gradle and gradle-wrapper.properties - and then doing a gradle sync in Android Studio.
Hi everybody I'm in a dead end!
Develop a PCL application using VisualStudio 2015, Xamarin and MvvmCross.
The Android app exceeds the 65K limit. I need to use Multidex!
For its implementation I have undertaken these guidelines:
Enabled checkbox for MultiDex
Extended MultiDexApplication class
General considerations:
Debug mode
MinSdk: 21
TargetSdk: 25
BuildTools: 23.0.3
Jdk 1.8.0_121
Xamarin.Android 7.3
Results:
"java.exe" exited with code 2. C:\Program Files (x86)\MSBuild\Xamarin \Android\Xamarin.Android.Common.targets 1965
<!-- Compile java code to dalvik -->
<CompileToDalvik
DxJarPath="$(DxJarPath)"
JavaToolPath="$(JavaToolPath)"
JavaMaximumHeapSize="$(JavaMaximumHeapSize)"
JavaOptions="$(JavaOptions)"
ClassesOutputDirectory="$(IntermediateOutputPath)android\bin\classes"
ToolPath="$(DxToolPath)"
ToolExe="$(DxToolExe)"
UseDx="$(UseDx)"
MultiDexEnabled="$(AndroidEnableMultiDex)"
MultiDexMainDexListFile="$(_AndroidMainDexListFile)"
JavaLibrariesToCompile="#(_JavaLibrariesToCompileForAppDx)"
OptionalObfuscatedJarFile="$(IntermediateOutputPath)proguard\__proguard_output__.jar"
/>
The error occurs during the compilation process.
I have consulted these sources:
"https://developer.android.com/studio/build/multidex.html"
"http://www.jon-douglas.com/2016/09/05/xamarin-android-multidex/"
"http://www.jon-douglas.com/2016/09/23/xamarin-android-multidex-keep/"
"https://przemekraciborski.eu/"
"https://forums.xamarin.com/discussion/64234/multi-dex-app-with-a-custom-application-class-that-runs-on-pre-lollipop"
"http://frogermcs.github.io/MultiDex-solution-for-64k-limit-in-Dalvik/"
I also have the ClassyShark.jar tool, but no dex or apk file is generated to explore it. Only the mono.android.jar file exists
Please I need help.
Thank you very much.
Responding to answer 1 and Luke Pothier's commentary are the results:
Setting output verbosity = Diagnostic
Case 1:
Using Android Sdk Location: C:\Program Files (x86)\Android\android-sdk installed with Visual Studio 2015.
4>_CompileToDalvikWithDx:
4> Creating directory "obj\Debug\proguard".
4> C:\Program Files\Java\jdk1.8.0_121\\bin\java.exe -Xmx1G -jar "C:\Program Files (x86)\Android\android-sdk\build-tools\25.0.3\\lib\dx.jar" --no-strict --dex --output= ...
4> trouble writing output: Too many field references: 68102; max is 65536.
4> You may try using --multi-dex option.
4> References by package:
(list of references by packages)
4>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1965,3): error MSB6006: "java.exe" exited with code 2.
Case 2:
Using Android Sdk Location: c:\android\sdk with last proguard version 5.3.3 installed with Android Studio.
4>_CompileToDalvikWithDx:
4> Creating directory "obj\Debug\proguard".
4> C:\Program Files\Java\jdk1.8.0_121\\bin\java.exe -Xmx1G -jar C:\Android\sdk\build-tools\25.0.0\\lib\dx.jar --no-strict --dex --output=
4> trouble writing output: Too many field references: 68102; max is 65536.
4> You may try using --multi-dex option.
4> References by package:
(list of references by packages)
4>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1965,3): error MSB6006: "java.exe" exited with code 2.
This is likely to be caused by an issue between Xamarin and ProGuard, the fix to which is detailed here. Essentially, you need to replace the proguard.jar file that is in your Android SDK directory with the latest one from SourceForge (v5.3.3 currently).
EDIT: Per the error messages in your edits, the --multi-dex option isn't being passed during compilation. I would check your Android .csproj to make sure that the <AndroidEnableMultiDex> option is set to True for all build configurations. If that doesn't help, you may need to upload a reproducible sample somewhere.
EDIT 2: Per the comments, your Android SDK location needs to be somewhere where the path does not contain spaces. Program Files is no good. Personally I put mine in C:\Android\android-sdk.
After adjusting the path to the android sdk, removing the spaces and setting in the project file for the Droid platform the property AndroidEnableMultiDex in all configurations (appeared AndroidEnableMultipleDex) in true, I was able to compile without errors. Also, I have been able to check the contents of the generated dex files and both have references to Mvvmcross.
When I execute the application, it shows the splash view (ok!!!), but, an exception occurs when processing the view (activity) that has a binded viewmodel. Now, the viewmodel has null value. (Until the moment of having to activate the multidex, the application executed without any incidence)
My challenge now is to know if all the reference to Mvvmcross should be in the main dex, or is it due to another problem that I have overlooked?
Thanks in advance for his time to #LukePothier.
My self response:
After compiling and generate dex classes:
use dex2jar & jd-gui tools following Jon Douglas' hints in http://www.jon-douglas.com/2016/09/23/xamarin-android-multidex-keep/.
be very patient and persevere.
remove innesesary code and plugin if you can do it yourself.
I already have the application running !!!
Today when I tried to upload an update of my app, I got this from Google Play console:
UPLOAD NEW APK TO PRODUCTION
Upload failed Your APK cannot be analyzed using 'aapt dump badging'.
Error output: Failed to run aapt dump badging: ERROR getting
'android:value' attribute for meta-data:attribute could not be found
I can upload normally before. I haven't made any change in AndroidManifest.xml.
The app is built via ant. I also tried building it again, even with the last-known-good code, the same error occurs.
Should I report this to Google Play team, or is it a known issue of Google Play?
Is there any work around?
It's now acknowledged by Google:
Some developers have reported seeing the error "Failed to run aapt dump badging: ERROR getting 'android:value' attribute for meta-data:attribute could not be found" when attempting to upload their .apk.
We're working on solving this problem. In the meantime, you can try adding the "android:value" to any meta-data manifest property that lacks that attribute. See API Guides - for more information.
https://support.google.com/googleplay/android-developer/known-issues/24493
I had the exact same problem, but managed to fix it now.
The problem is definitely in your manifest file. For me it was the Samsung MultiWindow feature. I found the solution here: Google Code Issue 46311
I had to change
<meta-data android:name="com.sec.android.multiwindow.DEFAULT_SIZE_W" android:resource="#dimen/app_defaultsize_w"/>
<meta-data android:name="com.sec.android.multiwindow.DEFAULT_SIZE_H" android:resource="#dimen/app_defaultsize_h"/>
into
<meta-data android:name="com.sec.android.multiwindow.DEFAULT_SIZE_W" android:value="632dp"/>
<meta-data android:name="com.sec.android.multiwindow.DEFAULT_SIZE_H" android:value="598dp"/>
Worked fine since yesterday, but now i had to change it.
Hope it helps.
Same problem here after generating new apk for alpha release with same certificate I get the error (in Dutch):
Upload mislukt
Uw APK kan niet worden geanalyseerd met 'aapt dump badging'. Foutuitvoer:
Failed to run aapt dump badging:
ERROR getting 'android:value' attribute for meta-data:attribute could not be found
I found one place in my Manifest where I use android:value for samsun multiwindow support.
<meta-data
android:name="com.sec.android.support.multiwindow"
android:value="true" />
I removed that from the Manifest. generated new apk (after project clean rebuild) and got the same error. This Manifest worked in my apk when uploading a previous version two weeks ago.
Use
android:name="some string value"
Instead of
android:name="#string/name_of_string_resource"
In my case, when building for ionic I forgot to add the .aab extension in the command land
I entered this into the cmd line
zipalign -v 4 app-release.aab appname_2.0.0
instead of
zipalign -v 4 app-release.aab appname_2.0.0.aab
I have just started with android in Eclipse and now i want to do the same in netbeans 6.8, i Configured netbeans with all the (andoird's)jar files..etc..whatever it asked me to do.,now it is possible to open the android project in the my netbeans 6.8, but the problem that i get now,
While i try to start new Android Project,Its getting opened and in the console ,its saying that build is successful,after i code the simple helloworld app and once i clean and build the app,its showing me as Build failed..Please help me to rectify the same..
I am very much annoyed becos of this problem for the last 2 days..
This is the error that i got...
Created dir: C:\Android Practices\workspace\AndroidApplication2\dist
=C:\Android was unexpected at this time.
C:\Android Practices\workspace\AndroidApplication2\nbproject\build-impl.xml:411: exec returned: 255
BUILD FAILED (total time: 0 seconds)
I had this same problem and it seems to come from the whitespaces existing in the path. Try changing the directory name to one without white spaces or change the path in the ant to something like this:
<project ... >
<property file="local.properties" />
<property name="sdk.dir" value="C:\Docume~1\user\android-sdk-windows" />
...
which is what solved my problem. Notice that Docume~1 is exactly 8 character long, I remember that was important.
I hope that helps.
Edit: I updated the answer to mark where to add the line, but unless your local.properties file contains something else apart from the definition of the sdk.dir, you can delete that line