java.lang.RuntimeException: Unable to start activity ComponentInfo

前端 未结 6 1522
误落风尘
误落风尘 2020-12-09 13:00

I know this error appeared on forum million of times, but please help me find what I missed. I\'m trying to do simple tab orientated application,I don\'t have much (except e

相关标签:
6条回答
  • 2020-12-09 13:26

    It was my own stupidity:

    java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext());
    

    Putting this inside onCreate() method fixed my problem.

    0 讨论(0)
  • 2020-12-09 13:28

    I had the same issue, I cleaned and rebuilt the project and it worked.

    0 讨论(0)
  • 2020-12-09 13:29

    After trying few answers they are either not related to my project or , I have tried cleaning and rebuilding (https://stackoverflow.com/a/48760966/8463813). But it didn't work for me directly. I have compared it with older version of code, in which i observed some library files(jars and aars in External Libraries directory) are missing. Tried Invalidate Cache and Restart worked, which created all the libraries and working fine.

    0 讨论(0)
  • 2020-12-09 13:33

    Your Manifest Must Change like this Activity name must Specified like ".YourActivityname"

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.th.mybook"
    android:versionCode="1"
    android:versionName="1.0" >
    
    <uses-sdk
         android:minSdkVersion="8" android:targetSdkVersion="8" />
    
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".MainTabPanel"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MyBookActivity"  >            
        </activity>
    </application>
    

    0 讨论(0)
  • 2020-12-09 13:36
        <activity
            android:name="MyBookActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.ALTERNATIVE" />
            </intent-filter>
        </activity>
    

    where is your dot before MyBookActivity?

    0 讨论(0)
  • 2020-12-09 13:36

    Dear You have used two Intent launcher in your Manifest. Make only one Activity as launcher: Your manifest activity is :

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="org.th.mybook"
        android:versionCode="1"
        android:versionName="1.0" >
        <uses-sdk android:minSdkVersion="8" />
        <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" >
            <activity
                android:name=".MainTabPanel"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity
                android:name="MyBookActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.ALTERNATIVE" />
                </intent-filter>
            </activity>
        </application>
    </manifest>
    

    now write code will be ( i have made your 'MyActivityBook' your default activity launcher. Copy and paste it on your manifest.

    <?xml version="1.0" encoding="utf-8"?>
        <manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="org.th.mybook"
            android:versionCode="1"
            android:versionName="1.0" >
            <uses-sdk android:minSdkVersion="8" />
            <application
                android:icon="@drawable/ic_launcher"
                android:label="@string/app_name" >
                <activity
                    android:name=".MainTabPanel"
                    android:label="@string/app_name" >
    
                </activity>
                <activity
                    android:name="MyBookActivity"
                    android:label="@string/app_name" >
                    <intent-filter>
                        <action android:name="android.intent.action.MAIN" />
                        <category android:name="android.intent.category.LAUNCHER" />
                    </intent-filter>
                </activity>
            </application>
        </manifest>
    

    and Second error may be if you copy paste old code then please update com.example.packagename.FILE_NAME

    hope this will work !

    0 讨论(0)
提交回复
热议问题