简体   繁体   English

Android Studio出现Ionic Build错误。

[英]Ionic Build error with Android Studio.

I have made functional changes in my ionic app and tested in browser by ionic serve. 我已经在离子应用程序中进行了功能更改,并在浏览器中通过离子服务进行了测试。 Everything went fine and proceeded for ionic build. 一切顺利,并进行离子生成。 So it returned me below error. 因此它返回我以下错误。

I:\myprojects\fizion>ionic package info 30

  id       │ 30
  status   │ FAILED
  platform │ android
  mode     │ debug
  started  │ Jul 30th, 2017 10:32:28

output:

ANDROID_HOME=/opt/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: /opt/android-sdk/tools/templates/gradle/wrapper

I am not sure whose Android SDK it is suggesting to upgrade. 我不确定建议升级谁的Android SDK。 Mine or ionic cloud's ? 矿山还是离子云的? Ok, I tried to upgrade my android studio SDK and then other problem started. 好的,我尝试升级我的android studio SDK,然后其他问题开始了。 Then I have issued below command to propogate the new changes to the android. 然后,我发出了以下命令,将新更改传播给android。

cordova prepare android

I have built the .apk file and launched in phone. 我已经建立了.apk文件并在手机中启动了。 It crashed, so tried in emulator and got the below error. 它崩溃了,所以在模拟器中尝试了并得到以下错误。

--------- beginning of crash
07-30 12:18:53.350 3040-3040/com.ionicframework.fizion233539 E/AndroidRuntime: FATAL EXCEPTION: main
                                                                               Process: com.ionicframework.fizion233539, PID: 3040
                                                                               java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ionicframework.fizion233539/com.ionicframework.fizion233539.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.ionicframework.fizion233539.MainActivity" on path: DexPathList[[zip file "/data/app/com.ionicframework.fizion233539-1/base.apk"],nativeLibraryDirectories=[/data/app/com.ionicframework.fizion233539-1/lib/x86_64, /vendor/lib64, /system/lib64]]
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                   at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                   at android.os.Looper.loop(Looper.java:148)
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                                Caused by: java.lang.ClassNotFoundException: Didn't find class "com.ionicframework.fizion233539.MainActivity" on path: DexPathList[[zip file "/data/app/com.ionicframework.fizion233539-1/base.apk"],nativeLibraryDirectories=[/data/app/com.ionicframework.fizion233539-1/lib/x86_64, /vendor/lib64, /system/lib64]]
                                                                                   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                                   at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                                                   at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                                                   at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                   at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                   at android.os.Looper.loop(Looper.java:148) 
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                                Suppressed: java.lang.NoClassDefFoundError: com.ionicframework.fizion233539.MainActivity
                                                                                   at dalvik.system.DexFile.defineClassNative(Native Method)
                                                                                   at dalvik.system.DexFile.defineClass(DexFile.java:226)
                                                                                   at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
                                                                                   at dalvik.system.DexPathList.findClass(DexPathList.java:338)
                                                                                   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
                                                                                        ... 13 more
                                                                                Suppressed: java.lang.ClassNotFoundException: com.ionicframework.fizion233539.MainActivity
                                                                                   at java.lang.Class.classForName(Native Method)
                                                                                   at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                                                   at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                                                   at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                                                        ... 12 more
                                                                                Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
07-30 12:18:53.352 1584-1596/system_process W/ActivityManager:   Force finishing activity com.ionicframework.fizion233539/.MainActivity

my manifest file: 我的清单文件:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.ionicframework.fizion233539" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:host="https://hs7pj.app.goo.gl/" android:scheme="https" />
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:host="fizion-f4286.firebaseapp.com" android:path="/__/auth/callback" android:scheme="https" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
    <uses-feature android:name="android.hardware.location.gps" />
</manifest>

I have been going through many SO posts and tried many but nothing worked out. 我经历了很多SO帖子,尝试了很多,但没有解决。 I am happy to share my android studio screenshots for configurations. 我很高兴分享我的android studio屏幕截图以进行配置。 I am sure this is due to upgrade of android studio but where to crack it. 我敢肯定这是由于android studio的升级,但破解它。

Could someone guide me I am blocked. 有人可以指导我,我被阻止了。

My android studio was showing me warning mentioned in the below post. 我的android studio向我显示了以下帖子中提到的警告。 So I ignored it. 所以我忽略了它。 But that is the culprit and fixed the issue. 但这是罪魁祸首,并解决了这个问题。

Android, IntelliJ Idea, changing module type Android,IntelliJ Idea,更改模块类型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM