gpt4 book ai didi

java - 手动编译android应用程序的麻烦

转载 作者:可可西里 更新时间:2023-11-01 10:35:24 26 4
gpt4 key购买 nike

我正在尝试使用我在此处找到的一些详细信息手动编译我的 Android 应用程序:

http://geosoft.no/development/android.html

一切正常。我现在可以编译我自己的应用程序而不需要除我之外的任何工具。这意味着没有 Gradle 也没有 Android studio。它运行完美,除非我需要编译使用 Google Play 库的应用程序。

我想做的是在我的布局中创建一个 Google map 实例,如下所示:

setContentView(R.layout.mymap_layout);

应用程序因以下错误而崩溃:

E/AndroidRuntime(26119): FATAL EXCEPTION: main
E/AndroidRuntime(26119): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
E/AndroidRuntime(26119): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
E/AndroidRuntime(26119): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
E/AndroidRuntime(26119): at android.app.Activity.onCreateView(Activity.java:4703)
E/AndroidRuntime(26119): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
E/AndroidRuntime(26119): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
E/AndroidRuntime(26119): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
E/AndroidRuntime(26119): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
E/AndroidRuntime(26119): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:306)
E/AndroidRuntime(26119): at android.app.Activity.setContentView(Activity.java:1901)
E/AndroidRuntime(26119): at com.Actividad.Brian.actividad.Google_Maps(actividad.java:2377)
E/AndroidRuntime(26119): at com.Actividad.Brian.actividad$4.run(actividad.java:1063)
E/AndroidRuntime(26119): at android.os.Handler.handleCallback(Handler.java:615)
E/AndroidRuntime(26119): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(26119): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(26119): at android.app.ActivityThread.main(ActivityThread.java:4918)
E/AndroidRuntime(26119): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(26119): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(26119): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
E/AndroidRuntime(26119): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
E/AndroidRuntime(26119): at dalvik.system.NativeStart.main(Native Method)

这是我正在使用的命令行:

// CHECKS THE SHA1 FINGERPRINT OF THE KEYSTORE. (NOT USED FOR V2 OF GOOGLE MAPS). 
C:\Program Files\Java\jdk1.7.0_71\bin\keytool.exe
-list -keystore "c:\users\brian\documents\Compiler\KeyStore\informes.keystore" -storepass ************** -keypass ********** -alias informes

// COMPILES THE RESOURCES.
C:\Users\brian\AppData\Local\Android\sdk\android-sdk\build-tools\21.1.1\aapt.exe
package -f -m --auto-add-overlay -S c:\users\brian\appdata\local\android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res -S res -J src -M src\AndroidManifest.xml -I "C:\Users\brian\AppData\Local\Android\android-sdk\platforms\android-21\android.jar"

// COMPILES THE RESOURCE CLASS.
C:\Program Files\Java\jdk1.7.0_71\bin\javac.exe
-d android\bin -classpath "C:\Users\brian\AppData\Local\Android\android-sdk\platforms\android-21\android.jar";android\obj;"C:\Users\brian\AppData\Local\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\libs\google-play-services.jar";"C:\Users\brian\AppData\Local\Android\android-sdk\extras\android\support\v4\android-support-v4.jar" -target 1.5 -source 1.5 -version -Xlint:none -version -encoding UTF-8 -sourcepath android\src android\src\com\Actividad\Brian\*.java

//COMPILES THE JAVA CLASS (USER'S CODE).
C:\Program Files\Java\jdk1.7.0_71\bin\javac.exe
-d android\bin -verbose -Xlint -classpath "C:\Users\brian\AppData\Local\Android\android-sdk\platforms\android-21\android.jar"";""android\obj;C:\Users\brian\AppData\Local\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\libs\google-play-services.jar";"C:\Users\brian\AppData\Local\Android\android-sdk\extras\android\support\v4\android-support-v4.jar" -sourcepath android\src android\src\com\Actividad\Brian\*.java

// CREATES THE DEX FILE (ANDROID'S EXECUTABLE).
C:\Program Files\Java\jdk1.7.0_71\bin\java.exe
-Xms1024m -Xmx2048m -jar "C:\Users\brian\AppData\Local\Android\sdk\android-sdk\build-tools\21.1.1\lib\dx.jar" --dex --output="C:\Users\brian\Documents\Compiler\Temp\android\bin\classes.dex" "C:\Users\brian\Documents\Compiler\Temp\android\bin" "C:\Users\brian\AppData\Local\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\libs\google-play-services.jar" "C:\Users\brian\AppData\Local\Android\android-sdk\extras\android\support\v4\android-support-v4.jar"

// COMPILES THE APK EXECUTABLE. (UNSIGNED)
C:\Users\brian\AppData\Local\Android\sdk\android-sdk\build-tools\21.1.1\aapt.exe
package -f --auto-add-overlay -M "C:\Users\brian\Documents\Compiler\Temp\android\src\AndroidManifest.xml" -S c:\users\brian\appdata\local\android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res -S "C:\Users\brian\Documents\Compiler\Temp\android\res" -A "C:\Users\brian\Documents\Compiler\Temp\android\assets" -I "C:\Users\brian\AppData\Local\Android\android-sdk\platforms\android-21\android.jar" -F "C:\Users\brian\Documents\Compiler\Temp\android\bin\actividad.unsigned.apk" "C:\Users\brian\Documents\Compiler\Temp\android\bin"

// SIGNS THE APK EXECUTABLE.
C:\Program Files\Java\jdk1.7.0_71\bin\jarsigner.exe
***IRRELEVANT, AND NOT POSTED BECAUSE OF KEYS***

//LIST THE DEVICES.
C:\Users\brian\AppData\Local\Android\sdk\android-sdk\platform-tools\adb.exe
devices

// GETS THE NAME OF THE PLUGGED DEVICE
C:\Users\brian\AppData\Local\Android\sdk\android-sdk\platform-tools\adb.exe
-s 1c523b41 shell getprop ro.product.model

// CLEARS THE LOGCAT.
C:\Users\brian\AppData\Local\Android\sdk\android-sdk\platform-tools\adb.exe
logcat -c

// INSTALLS THE COMPILED APK.
C:\Users\brian\AppData\Local\Android\sdk\android-sdk\platform-tools\adb.exe
-e -s 1c523b41 install -r C:\Users\brian\Documents\Compiler\Temp\android\bin\actividad.apk

// RUNS IT.
C:\Users\brian\AppData\Local\Android\sdk\android-sdk\platform-tools\adb.exe
shell am start -n com.Actividad.Brian/.actividad

// DISPLAYS THE LOGCAT AFTER THE CRASH.
C:\Users\brian\AppData\Local\Android\sdk\android-sdk\platform-tools\adb.exe
logcat

我认为我没有正确包含 Google Play JAR,但我看不出错误在哪里....

有什么想法吗?

最佳答案

原来我只需要单独编译资源。喜欢这个

// COMPILES THE LIBRARY CLASS.
package -f -m --auto-add-overlay -S "C:\Users\Brian\AppData\Local\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res" -J "C:\Users\Brian\Documents\output\Temp\android\src" -M "C:\Users\Brian\AppData\Local\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\AndroidManifest.xml" -I "C:\Users\Brian\AppData\Local\Android\android-sdk\platforms\android-22\android.jar"

我不知道那里有两个独立的进程,我认为这两个资源应该由同一个命令行编译。

关于java - 手动编译android应用程序的麻烦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30342111/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com