今天我创建了一个示例应用程序“我的应用程序”,其中包含所有基本配置,如
compileSdkVersion 22
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.development.av.myapplication"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
只有一个活动显示hello world text。
甚至,我的清单文件没有任何权限。
当我在我的测试设备上运行此应用程序时。它运行良好。这是有Android版本... 5.1.1
然后我把这个应用程序发送到我的另一个安卓版6.0的Android设备 但是这个设备没有打开这个应用程序。 安装成功。 但是当我打开这个应用程序时,它给了我一个错误说, image1
当我点击尝试解决它时,会给另一个屏幕显示选项清除数据...点击后它会给我另一个屏幕“应用信息”屏幕...
但我不明白我的应用程序有什么问题? 有人请建议......
我更新的构建配置如下
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.development.av.myapplication"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
但没有运气!!!!
以下是我的应用
的完整源代码的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.development.av.myapplication"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.development.av.myapplication.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
MainActivity.java
package com.development.av.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.development.av.myapplication">
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
答案 0 :(得分:0)
如果您确实想要在API 23及更早版本上运行
,则需要compileSdk 23
既然您正在使用构建工具26,那么您也可以使用26
进行编译答案 1 :(得分:0)
要在Android 6上运行您的应用,请使用:
targetSdkVersion 23 and compileSdkVersion 23
而不是
targetSdkVersion 22 and compileSdkVersion 22
建议您使用以下代码支持Android Oreo之前的所有设备
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.development.av.myapplication"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"