Java 在Android上启用USB调试时出错

Java 在Android上启用USB调试时出错,java,android,android-studio,developer-tools,usb-debugging,Java,Android,Android Studio,Developer Tools,Usb Debugging,我正在尝试根据为我的项目启用USB调试。然而,当我在build.gradle文件中写下这一点时: android { buildTypes { debug { debuggable true } android:debuggable="true" /* Top-level build file where you can add configuration options common to all sub-projects/modules.*/ build

我正在尝试根据为我的项目启用USB调试。然而,当我在build.gradle文件中写下这一点时:

android {
buildTypes {
    debug {
        debuggable true
    }
android:debuggable="true"
/* Top-level build file where you can add configuration options common to all sub-projects/modules.*/

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

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

allprojects {
    repositories {
        jcenter()
    } 
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
我得到一个错误,说:

错误:(25,0)找不到Gradle DSL方法:“android()” 可能原因:
  • 项目“检查”可能使用的Gradle版本不包含该方法。 Gradle设置生成文件可能缺少Gradle插件。 应用Gradle插件
  • 当我尝试从AndiodManifest文件启用USB调试时(不修改build.gradle文件):

    我得到一个错误,说:

    避免硬编码调试模式;省略它允许调试和发布版本自动分配一个更少的。。。(Ctrl+F1) 最好在清单中省略android:debugable属性。如果您这样做,那么在构建APK以在模拟器或设备上进行调试时,这些工具将自动插入android:debuggable=true。当您执行发布构建(例如导出APK)时,它会自动将其设置为false。另一方面,如果您在清单文件中指定了一个特定的值,那么工具将始终使用它。这可能会导致意外发布包含调试信息的应用程序

    我已经尝试了文档中提到的两种方法。如何启用USB调试

    编辑(这是build.gradle文件):


    你已经在你的设备上启用USB调试了吗?发布你的
    build.gradle
    @Alok Gupta是的,我已经启用了。但我甚至没有在我的设备上进行调试。我发现文件本身有错误。@IntelliJAmiya我已将其作为编辑添加到问题中。