Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
404 views
in Technique[技术] by (71.8m points)

apk - App building process works for Android 6.0.1, but not for 2.3.6

I want my Android apps to work also on old Android versions. This hello world app, which I have written, works on my Android 6.0.1 device, but is not installed to my Android 2.3.6 device (error message: Application not installed). I find the following messages in my log extracted by adb:

D/PackageParser( 1464): Scanning package: /data/app/vmdl953816991.tmp
I/PackageParser( 1464): org.kolodez.HelloWorld: compat added android.permission.WRITE_EXTERNAL_STORAGE android.permission.READ_PHONE_STATE
W/PackageParser( 1464): Exception reading AndroidManifest.xml in /data/app/vmdl953816991.tmp
W/PackageParser( 1464): java.lang.SecurityException: META-INF/MYALIAS.SF has invalid digest for classes.dex in /data/app/vmdl953816991.tmp
W/PackageParser( 1464):     at java.util.jar.JarVerifier.invalidDigest(JarVerifier.java:130)
W/PackageParser( 1464):     at java.util.jar.JarVerifier.verifyCertificate(JarVerifier.java:357)
W/PackageParser( 1464):     at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:265)
W/PackageParser( 1464):     at java.util.jar.JarFile.getInputStream(JarFile.java:389)
W/PackageParser( 1464):     at android.content.pm.PackageParser.loadCertificates(PackageParser.java:342)
W/PackageParser( 1464):     at android.content.pm.PackageParser.collectCertificates(PackageParser.java:513)
W/PackageParser( 1464):     at com.android.server.PackageManagerService.installPackageLI(PackageManagerService.java:5996)
W/PackageParser( 1464):     at com.android.server.PackageManagerService.access$2200(PackageManagerService.java:142)
W/PackageParser( 1464):     at com.android.server.PackageManagerService$5.run(PackageManagerService.java:4750)
W/PackageParser( 1464):     at android.os.Handler.handleCallback(Handler.java:587)
W/PackageParser( 1464):     at android.os.Handler.dispatchMessage(Handler.java:92)
W/PackageParser( 1464):     at android.os.Looper.loop(Looper.java:130)
W/PackageParser( 1464):     at android.os.HandlerThread.run(HandlerThread.java:60)
E/PackageParser( 1464): Package org.kolodez.HelloWorld has no certificates at entry AndroidManifest.xml; ignoring!

What did I do wrong?

Edit: It is also running on my Android 5.0.2. So the fact that I used android-23/android.jar and API 23 is supported only on Android 6 and later is not the reason.

Here are the build instructions:

aapt package -v -f -m -S ./src/res/ -J ./src/src/ -M ./src/AndroidManifest.xml -I /usr/lib/android-sdk/platforms/android-23/android.jar
javac -d ./obj/ -source 1.7 -target 1.7 -classpath /usr/lib/android-sdk/platforms/android-23/android.jar -sourcepath ./src/src/ ./src/src/org/kolodez/HelloWorld/*
/usr/lib/android-sdk/build-tools/27.0.1/dx --dex --output=./bin/classes.dex ./obj/
aapt package -f -M ./src/AndroidManifest.xml -S ./src/res/ -I /usr/lib/android-sdk/platforms/android-23/android.jar -F ./bin/HelloWorld.unsigned.apk ./bin
keytool -genkeypair -validity 10000 -dname "CN=Kolodez, OU=Kolodez, O=Kolodez, C=US" -keystore ./key/mykey.keystore -storepass mypass -keypass mypass -alias myalias -keyalg RSA
jarsigner -keystore ./key/mykey.keystore -storepass mypass -keypass mypass -signedjar ./bin/HelloWorld.signed.apk ./bin/HelloWorld.unsigned.apk myalias
zipalign -f 4 ./bin/HelloWorld.signed.apk ./bin/HelloWorld.apk
question from:https://stackoverflow.com/questions/65648299/app-building-process-works-for-android-6-0-1-but-not-for-2-3-6

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...