我通过添加第二个活动对代码进行了修改,现在出现此错误:
01/20 07:14:24: Launching 'app' on 10.1 WXGA (Tablet) API 26.
Installation did not succeed. The application could not be installed:
INSTALL_FAILED_OLDER_SDK
List of apks: [0]
'C:\Users\Moi\Desktop\EscapeGameSTW\app\build\outputs\apk\debug\app-debug.apk'
The application's minSdkVersion is newer than the device API level.
AndroidiManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-feature android:name="android.hardware.type.watch" />
<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/Theme.AppCompat.NoActionBar">
<uses-library
android:name="com.google.android.wearable"
android:required="true" />
<!--
Set to true if your app is Standalone, that is, it does not require the handheld
app to run.
-->
<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />
<activity
android:name=".MainActivity"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle 文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 27
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.3.1'
implementation 'androidx.wear:wear:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
compileOnly 'com.google.android.wearable:wearable:2.5.0'
}
我必须使用的 deviceSDK 是 API26。
我已经删除了修改,但错误仍然发生。 我试图将 compileSdkVersion 更改为 26 如何恢复此错误?
感谢每一个人。
答案 0 :(得分:1)
我发现了我的问题。这是由于图书馆可穿戴。删除后一切正常
<uses-library
android:name="com.google.android.wearable"
android:required="true" />
最大
答案 1 :(得分:0)
您的移动设备 API level
低于您项目的最低 Sdk 版本
在gradle中:
defaultConfig {
applicationId "com.example.myapplication"
//You have to decrease the minSdkVersion cause, your android's API level is lower than this. minSdkVersion used for from which API level of android you can use
minSdkVersion 27
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
所以,试试
minSdkVersion 20
如果可能,它也必须与您的源代码兼容。只需根据您的 android 的 API 级别更改它