我正在开发一款应用。当我在api级别21(Lollipop设备)上运行应用程序时,应用程序崩溃了。而我正在获得资源未找到的例外。但是当我在R.java
中检查此资源ID时,资源ID可用。请告诉我是什么原因。
CODE
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.bravoslimo.activities.SplashActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/NoTitleStyle" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
这是r.java
public static final int activity_locaton=0x7f03001a;
public static final int activity_login=0x7f03001b;
public static final int activity_payment=0x7f03001c;
public static final int activity_reservation_confirmation=0x7f03001d;
public static final int activity_splash=0x7f03001e;
public static final int activity_terms_and_condition=0x7f03001f;
public static final int center_action_bar_text=0x7f030020;
public static final int com_facebook_friendpickerfragment=0x7f030021;
public static final int com_facebook_login_activity_layout=0x7f030022;
public static final int com_facebook_picker_activity_circle_row=0x7f030023;
这是我的代码
package com.bravoslimo.activities;
public class SplashActivity extends Activity implements
OnAsynTaskFinishedListener {
@SuppressLint("SimpleDateFormat")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
AndroidUtils.getHashKey(SplashActivity.this);
// Calling the getCountry API
if (ConnectivityController.isNetworkAvailable(SplashActivity.this)) {
GetCountryAsynTask countryAsynTask = new GetCountryAsynTask(
SplashActivity.this, ConstantsUtils.API_ID,
ConstantsUtils.API_KEY);
countryAsynTask.setOnAsynTaskFinishedListener(this);
countryAsynTask.execute();
//startActivity(new Intent(SplashActivity.this, TermsAndConditions.class));
//selectAvtivityToStart();
} else {
showAlartDialog();
}
}
@Override
public void OnAsynTaskFinished(String asynTaskName) {
}
}
日志
03-10 14:35:24.435: E/AndroidRuntime(2511): Process: com.bravoslimo, PID: 2511
03-10 14:35:24.435: E/AndroidRuntime(2511): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bravoslimo/com.bravoslimo.activities.SplashActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f03001e
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.app.ActivityThread.access$800(ActivityThread.java:144)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.os.Handler.dispatchMessage(Handler.java:102)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.os.Looper.loop(Looper.java:135)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.app.ActivityThread.main(ActivityThread.java:5221)
03-10 14:35:24.435: E/AndroidRuntime(2511): at java.lang.reflect.Method.invoke(Native Method)
03-10 14:35:24.435: E/AndroidRuntime(2511): at java.lang.reflect.Method.invoke(Method.java:372)
03-10 14:35:24.435: E/AndroidRuntime(2511): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
03-10 14:35:24.435: E/AndroidRuntime(2511): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
03-10 14:35:24.435: E/AndroidRuntime(2511): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f03001e
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.content.res.Resources.getValue(Resources.java:1233)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2598)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.content.res.Resources.getLayout(Resources.java:1049)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.view.LayoutInflater.inflate(LayoutInflater.java:412)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
03-10 14:35:24.435: E/AndroidRuntime(2511): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.app.Activity.setContentView(Activity.java:2144)
03-10 14:35:24.435: E/AndroidRuntime(2511): at com.bravoslimo.activities.SplashActivity.onCreate(SplashActivity.java:35)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.app.Activity.performCreate(Activity.java:5933)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
03-10 14:35:24.435: E/AndroidRuntime(2511): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
03-10 14:35:24.435: E/AndroidRuntime(2511): ... 10 more