【问题标题】:How to launch my application on my mobile? Error如何在我的手机上启动我的应用程序?错误
【发布时间】:2019-06-28 03:16:45
【问题描述】:

我想通过使用 android studio 关注 this tutorial 来制作一个启动画面。

(error in android studio)

当我运行命令“react-native run-android”时,我的应用程序拒绝运行并出现此错误:

:构建失败并出现异常。

  • 出了什么问题: 任务 ':app:transformClassesWithDexBuilderForDebug' 执行失败。 com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: 无法处理 C:\Users\veget.gradle\caches\transforms-1\文件-1.1\exoplayer-core-2.9.1.aar\472ffc49d344965c2b0eac59f4adcc13\jars\classes.jar

  • 尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。

  • 通过https://help.gradle.org获得更多帮助

8 秒后失败 89 个可操作的任务:1 个已执行,88 个最新 无法在设备上安装应用程序,请阅读上面的错误以了解详细信息。 确保您有一个正在运行的 Android 模拟器或连接的设备,并且有 设置您的 Android 开发环境: https://facebook.github.io/react-native/docs/getting-started.html

我应该怎么做才能在我的手机上启动我的应用程序?

【问题讨论】:

  • 请不要发布您的错误的屏幕截图。复制错误,编辑您的问题并将错误粘贴到其中。
  • @Leeli 只是干净地重建你的项目
  • @Andrew 感谢您在负面指出问题之前阻止,新成员不一定了解网站的所有规则,您的问题被愚蠢地组织起来,我们可以纠正它们。
  • @Sandeepdhiman 你是什么意思? :)
  • @Leeli 我没有对你投反对票。我刚刚评论了。

标签: javascript android android-studio react-native build


【解决方案1】:

进入 android studio 选择 Build/Rebuild 项目。在此之前尝试同步您的项目。这应该可以解决问题。

【讨论】:

  • 问题仍然存在。 “错误:仅从 Android O (--min-api 26) 开始支持调用自定义。问题是否来自 Gradle?不是吗?
  • 好的,在您的 app/build.gradle 中执行以下操作: android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } 如果您的 java 版本是 10 或 7,请像 1_10 或 1_7 一样进行操作跨度>
【解决方案2】:

在您的应用级别 build.gradle 中添加以下代码

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:design:28.0.0'
    }
}

【讨论】:

  • 错误:无法解决:com.android.support:appcompat-v7:28.0.3 在项目结构对话框中显示受影响的模块:react-native-splash-screen
  • @Leeli 将其放在 app/build.gradle 中
  • 是的,我这样做.. android { compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
  • @Leeli 我已经更新了我的答案,请用上面的代码替换你的 build.gradle
  • 我的更改也补充了我的依赖项?
猜你喜欢
  • 2012-10-19
  • 2021-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-28
相关资源
最近更新 更多