【问题标题】:Cannot run on production devices! error while running the app on USB attached device无法在生产设备上运行!在 USB 连接设备上运行应用程序时出错
【发布时间】:2016-12-23 17:24:57
【问题描述】:

我已通过 USB 连接我的手机以在我的手机上运行该应用程序。但在运行时,Android Monitor 显示错误

无法在生产设备上运行!

清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.roam12.demo">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

构建 Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "com.example.roam12.demo"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

【问题讨论】:

  • android:launchMode="standard"
  • 您添加了任何需要设备植根的内容?另外,分享您的build.gradle
  • 我把这个语句放在哪里,当我把它放在 Android Manifest 中时,它会给出错误“无法解析标准”.. :(
  • android:launchMode 您需要在清单中的活动中使用它
  • 好的..我试试这个...

标签: android android-studio error-handling


【解决方案1】:

您可能实际上并未通过签名向导对 APK 的发布版本进行签名。您可以使用以下命令从命令行构建发布 APK:

./gradlew assembleRelease

或者您可以从 Build Variants 视图中选择发布变体并从 GUI 构建它。

或者在你的 Build Gradle 文件中定义一个debug buildtype

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-18
    • 2011-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多