简体   繁体   English

无法启动活动 ComponentInfo{com.example.admin.testapplication/com.example.admin.testapplication.MainActivity}

[英]Unable to start activity ComponentInfo{com.example.admin.testapplication/com.example.admin.testapplication.MainActivity}

After launching the basic template with hello world in android studio I am facing an error in runtime在 android 工作室中使用 hello world 启动基本模板后,我在运行时遇到错误

1.xml code android manifest.xml 1.xml 代码 android 清单.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.admin.testapplication">

    <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">

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

2.activity code public class MainActivity extends AppCompatActivity { 2.activity code public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);

    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

} }

3.Error RuntimeException 3.Error RuntimeException

E/AndroidRuntime: FATAL EXCEPTION: main

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.admin.testapplication/com.example.admin.testapplication.MainActivity}: android.view.InflateException: Binary XML file line #21: Error inflating class com.google.android.gms.maps.MapView
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
    at android.app.ActivityThread.access$600(ActivityThread.java:141)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5103)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)
 Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class com.google.android.gms.maps.MapView
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
    at android.support.v7.app.k.c(:287)
    at android.support.v7.app.c.setContentView(:139)
    at com.example.admin.testapplication.MainActivity.onCreate(:17)
    at android.app.Activity.performCreate(Activity.java:5133)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 
    at android.app.ActivityThread.access$600(ActivityThread.java:141) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:137) 
    at android.app.ActivityThread.main(ActivityThread.java:5103) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:525) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
    at dalvik.system.NativeStart.main(Native Method) 
 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.MapView" on path: DexPathList[[zip file "/data/app/com.example.admin.testapplication-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.admin.testapplication-1, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    at android.view.LayoutInflater.createView(LayoutInflater.java:559)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
    at android.support.v7.app.k.c(:287) 
    at android.support.v7.app.c.setContentView(:139) 
    at com.example.admin.testapplication.MainActivity.onCreate(:17) 
    at android.app.Activity.performCreate(Activity.java:5133) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 
    at android.app.ActivityThread.access$600(ActivityThread.java:141) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:137) 
    at android.app.ActivityThread.main(ActivityThread.java:5103) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:525) 
    at 

com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:73)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method)在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 在 dalvik。

need help on this在这方面需要帮助

I tried to search on the errors that occured, but no luck.我试图搜索发生的错误,但没有运气。 then I got to know that I have to change the content.xml configuration.然后我知道我必须更改内容。xml 配置。 The changes that I have done in content.xml are "device for preview" and "api version for preview" accordingly the device which is running in the emulator我在 content.xml 中所做的更改是“用于预览的设备”和“用于预览的 api 版本”,因此在模拟器中运行的设备

暂无
暂无

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

相关问题 无法启动活动ComponentInfo {com.example.my_app / com.example.my_app.MainActivity}:java.lang.NullPointerException - Unable to start activity ComponentInfo{com.example.my_app/com.example.my_app.MainActivity}: java.lang.NullPointerException 无法启动活动ComponentInfo {com.example.countryselect / com.example.countryselect.OfferSelect} - Unable to start activity ComponentInfo{com.example.countryselect/com.example.countryselect.OfferSelect} java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.exp2 / com.example.exp2.MainActivity}:java.lang.NullPointerException - java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.exp2/com.example.exp2.MainActivity}: java.lang.NullPointerException 无法启动活动 ComponentInfo{com.example.mark/com.example.mark.BdaySelect} - Unable to start activity ComponentInfo{com.example.mark/com.example.mark.BdaySelect} 无法实例化活动ComponentInfo {com.example.ragefacefolks / com.example.ragefacefolks.MainActivity}:java.lang.NullPointerException - Unable to instantiate activity ComponentInfo{com.example.ragefacefolks/com.example.ragefacefolks.MainActivity}: java.lang.NullPointerException “无法启动活动ComponentInfo {com.example / com.artifex.mupdfdemo.MuPDFActivity}:java.lang.NullPointerException” - “Unable to start activity ComponentInfo{com.example/com.artifex.mupdfdemo.MuPDFActivity}: java.lang.NullPointerException” 无法启动活动ComponentInfo {com.example.list / com.example.list.editbox}:java.lang.NullPointerException - Unable to start activity ComponentInfo{com.example.list/com.example.list.editbox}: java.lang.NullPointerException java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.hometools / com.example.hometools.HometoolsActivity - java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hometools/com.example.hometools.HometoolsActivity java.lang.RuntimeException: 无法启动活动 ComponentInfo{com.example.foody/com.example.foody.StartActivity}: java.lang.NullPointerException - java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.foody/com.example.foody.StartActivity}: java.lang.NullPointerException java.lang.RuntimeException:无法实例化活动ComponentInfo {com.example.myfirstapp / com.example.myfirstapp.DisplayMessageActivity} - java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.myfirstapp/com.example.myfirstapp.DisplayMessageActivity}
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM