java.lang.RuntimeException:无法实例化活动,java.lang.ClassNotFoundException:未找到类,

时间:2019-09-15 16:42:15

标签: java android-studio arcore

尝试在手机(Android 8,三星S7)上运行我的应用程序时,它会打开,但立即关闭。我搜索了几个小时以找到修复程序,但是每次运行它时,logcat都会出现相同的错误。我似乎无法弄清楚我要去哪里。

记录猫错误:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.arlearning/com.example.arlearning.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.arlearning.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.arlearning-9IijsjiHVYUtlL0mDBitNQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.arlearning-9IijsjiHVYUtlL0mDBitNQ==/lib/arm64, /data/app/com.example.arlearning-9IijsjiHVYUtlL0mDBitNQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]

AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.arlearning">
<uses-permission android:name="android.permission.CAMERA"/>

    <uses-feature
        android:name="android.hardware.camera.ar"
        android:required="true" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <meta-data
            android:name="com.google.ar.core"
            android:value="required" />
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

MainActivity.Java文件


package com.example.arlearning;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.google.ar.sceneform.ux.ArFragment;

public class MainActivity extends AppCompatActivity {

    private ArFragment arFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        arFragment = (ArFragment)  getSupportFragmentManager().findFragmentById(R.id.ar_fragment);

        // hiding the plane discovery
        arFragment.getPlaneDiscoveryController().hide();
        arFragment.getPlaneDiscoveryController().setInstructionView(null);

    }
}

acitvity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">




    <fragment android:name="com.google.ar.sceneform.ux.ArFragment"
        android:id="@+id/ar_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</FrameLayout>

0 个答案:

没有答案