eclipse targetSdkVersion 设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24501374/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
targetSdkVersion setting
提问by Damian Lesniak
If someone could help me with this. I downloaded AndroidSDK and everything else needed for android programming, and I faced some problems with (funny to say) hello world.
如果有人能帮我解决这个问题。我下载了 AndroidSDK 和 android 编程所需的所有其他东西,但我遇到了一些(说起来很有趣)hello world 的问题。
I just do not get the thing with tarketSdkVersion setting in AppManifest. Whenever it is not set to "13" (just noticed 8 which is my minSdkVersion is working also) application has "Unfortunately application stopped working" screen with this in LogCat:
我只是不明白 AppManifest 中的 tarketSdkVersion 设置。每当它未设置为“13”时(刚刚注意到 8,我的 minSdkVersion 也在工作)应用程序在 LogCat 中有“不幸的应用程序停止工作”屏幕:
07-01 01:26:47.820: E/AndroidRuntime(902): FATAL EXCEPTION: main
07-01 01:26:47.820: E/AndroidRuntime(902): Process: pl.bbZoftware.eclipsestandalone, PID: 902
07-01 01:26:47.820: E/AndroidRuntime(902): java.lang.RuntimeException: Unable to start activity ComponentInfo{pl.bbZoftware.eclipsestandalone/pl.bbZoftware.eclipsestandalone.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.ActivityThread.access0(ActivityThread.java:138)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.os.Handler.dispatchMessage(Handler.java:102)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.os.Looper.loop(Looper.java:136)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.ActivityThread.main(ActivityThread.java:5026)
07-01 01:26:47.820: E/AndroidRuntime(902): at java.lang.reflect.Method.invokeNative(Native Method)
07-01 01:26:47.820: E/AndroidRuntime(902): at java.lang.reflect.Method.invoke(Method.java:515)
07-01 01:26:47.820: E/AndroidRuntime(902): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
07-01 01:26:47.820: E/AndroidRuntime(902): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
07-01 01:26:47.820: E/AndroidRuntime(902): at dalvik.system.NativeStart.main(Native Method)
07-01 01:26:47.820: E/AndroidRuntime(902): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-01 01:26:47.820: E/AndroidRuntime(902): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
07-01 01:26:47.820: E/AndroidRuntime(902): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
07-01 01:26:47.820: E/AndroidRuntime(902): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
07-01 01:26:47.820: E/AndroidRuntime(902): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.Activity.setContentView(Activity.java:1930)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
07-01 01:26:47.820: E/AndroidRuntime(902): at pl.bbZoftware.eclipsestandalone.MainActivity.onCreate(MainActivity.java:14)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.Activity.performCreate(Activity.java:5242)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
07-01 01:26:47.820: E/AndroidRuntime(902): ... 11 more
07-01 01:26:55.340: I/Process(902): Sending signal. PID: 902 SIG: 9
I do not get if this is intentional, I got some SDK errors or something else. I was googling for answers but coulnt find any. Tell me if I should add some more info from project, looking for your answers.
我不明白这是故意的,我遇到了一些 SDK 错误或其他问题。我在谷歌上搜索答案,但找不到任何答案。告诉我是否应该从项目中添加更多信息,寻找您的答案。
EDIT: Forgot to add, I got an android device with 4.4.2 KitKat so I wanted to make project target set to 20. That is how I noticed this errors.
编辑:忘了补充,我有一个 4.4.2 KitKat 的安卓设备,所以我想将项目目标设置为 20。这就是我注意到这个错误的方式。
EDIT2:
编辑2:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
activity_main.xml:
活动_main.xml:
<RelativeLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="pl.bbZoftware.eclipsestandalone.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
</RelativeLayout>
EDIT3:
编辑3:
manifest file:
清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pl.bbZoftware.eclipsestandalone"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="13" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
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>
回答by Damian Lesniak
I just found where the problem was.
我刚刚找到问题所在。
Do not use API Level of 20 and Platform 4.4W, as Android Virtual Device. With Level 19 and Platform 4.2.2 set on ADV everything runs as it should.
不要使用 API Level 20 和 Platform 4.4W,作为 Android 虚拟设备。在 ADV 上设置 Level 19 和 Platform 4.2.2 后,一切都按预期运行。
回答by user1784833
Just remove android:targetSdkVersion
from AndroidManifest.xml
只需android:targetSdkVersion
从 AndroidManifest.xml 中删除
Make following changes: From
进行以下更改:从
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
To:
到:
<uses-sdk android:minSdkVersion="8" />
回答by Selim ?zbudak
Most probably you are making mistake on activity_main.xml
很可能你在 activity_main.xml 上犯了错误
Also target for 4.4.2 Kitkat is 19. Have a check in this android api levels page.
4.4.2 Kitkat 的目标也是 19。检查这个android api 级别页面。
回答by VSB
ChangetargetSdkVersion
in [project directory]\app\build.gradle
to something less than or equal to 19. Change:
变化targetSdkVersion
中[project directory]\app\build.gradle
的东西小于或等于19的变化:
defaultConfig {
applicationId '....'
minSdkVersion 8
targetSdkVersion 21
}
To:
到:
defaultConfig {
applicationId '....'
targetSdkVersion 19
}
回答by nairashu
Android API 20 gives compilation issues. Make sure to be using the API 19 and set it as a Targeted SDK during development.
Android API 20 给出了编译问题。确保使用 API 19 并在开发期间将其设置为 Targeted SDK。