水之积也不厚,则其负大舟也无力 2018-04-25 15:13 采纳率: 100%
浏览 8598
已采纳

安卓开发:org.gradle.tooling.BuildException:

在真机上出现这个异常
org.gradle.tooling.BuildException: Exception while generating InstantRun main resources APK

在真机上运行出现这个异常

我的清单文件
<?xml version="1.0" encoding="utf-8"?>
xmlns:tools="http://schemas.android.com/tools"
package="com.example.lenovo.mynotebook">

<provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="com.example.lenovo.mynotebook.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/provider_paths" />
</provider>


<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
    tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.CAMERA" />
<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"
        android:windowSoftInputMode="adjustUnspecified|stateHidden"
        >

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".edit_activity"
        android:windowSoftInputMode="adjustUnspecified|stateHidden"
        >

    </activity>
</application>

 我的build.gradle(Project)
 // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}


 我的build.gradle(app) 
```apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.lenovo.mynotebook"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.android.support:support-v4:27.1.1'
}



  • 写回答

1条回答 默认 最新

  • ydw_ydw 2018-04-26 00:48
    关注

    因为依赖包的路径太长了。默认的情况下,gradle都在个人用户的目录下,有的人的名字长,有的名字短。名字长的一下子就溢出了,导致工程不能运行了。
    解决办法1
    把gradle的依赖包换一个地方。比如在eclipse中,通过gradle插件,直接修改目录即可。
    注意,新指定的目录不能为 .gradle或者类似 以.开头,否则会没有效果。

    依赖包太长的异常
    这个地方eclipse是乱码,所以定位问题就更加难了。

    CreateProcess error=206, ÎļþÃû»ò)չÃû
    Could not execute build using Gradle distribution ‘http://venus.vip.vip.com/tools/gradle/gradle-2.4-bin.zip‘.

    Caused by: java.io.IOException: Cannot run program “C:\Program Files\Java\jdk1.7.0_17\bin\java.exe” (in directory “D:\xxx\git_xxx\project\online\test-task-service”): CreateProcess error=206, ??????ò)???

    org.gradle.tooling.BuildException: Could not execute build using Gradle distribution ‘http://venus.vip.vip.com/tools/gradle/gradle-2.4-bin.zip‘.
    at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:57)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?