而错误的项目移植到Android工作室? [英] Errors while porting project to Android Studio?

查看:191
本文介绍了而错误的项目移植到Android工作室?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid Studio中,我一直在使用Eclipse的约2年。我想了解这些解决方案。

I'm new to Android Studio, I've been using Eclipse for about 2 years. I've trying understanding these solutions.

<一个href=\"http://stackoverflow.com/questions/26851230/android-gradle-build-error9-0-gradle-dsl-method-not-found-compile\">Android建立gradle这个错误:(9,0)摇篮DSL方法没有找到。编译()'

摇篮DSL方法未找到:'编译()'

我只是无法得到它的工作。

I just can't get it to work.

下面就是它说。

错误:(17,0)摇篮DSL方法未找到:'编译()
可能的原因:

  • 的项目'clxxxii - PMv5'可以使用一个版本的摇篮的不包含的方法。
    打开包装摇篮文件
  • 构建文件可能丢失一个摇篮插件。
    应用摇篮插件
  • Error:(17, 0) Gradle DSL method not found: 'compile()' Possible causes:

  • The project 'clxxxii - PMv5' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • 依赖不能被应用到'(groovy.lang.Closure)少...(⌘F1)
    该检验报告的分配不兼容类型

    'dependencies' cannot be applied to '(groovy.lang.Closure)' less... (⌘F1) This inspection reports assignments with incompatible types

    在此处,它给了一个错误文件

    Here's the file where it's giving an error

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.1.0'    }
    }
    
    allprojects {
        repositories {
            mavenCentral()
        }
    }
    dependencies {
        apply plugin: 'announce'
        compile 'com.android.support:appcompat-v7:21.0.0'
        compile 'com.android.support:cardview-v7:21.0.+'
    }
    

    和基于其他问题,您可能需要这一点。

    And based on the other questions, you may need this too.

    apply plugin: 'android'
    
    android {
        compileSdkVersion 17
        buildToolsVersion "19.0.3"
    
        defaultConfig {
            minSdkVersion 8
            targetSdkVersion 19
        }
    
        buildTypes {
            release {
                runProguard false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    }
    
    dependencies {
        compile 'com.android.support:support-v4:+'
        compile files('libs/FlurryAnalytics_3.3.0.jar')
        compile files('libs/heyzap-ads-sdk.jar')
        compile files('libs/HomeBaseSDK2.2.jar')
        compile files('libs/placed-persistent-sdk-1.10.jar')
        compile files('libs/revmob-6.7.0.jar')
    }
    

    有人可以帮助我了解的问题是什么,以及为什么它的发生?

    Can someone help me understand what the problem is, and why it's happening?

    推荐答案

    这可能无法完全回答你的问题,但也许你能得到你的项目的运行。
    这些依赖关系不要在你第一次的build.gradle文件属于:

    This might not fully answer your question but maybe you can get your project running. These dependencies dont belong in your first build.gradle file :

    dependencies {
    apply plugin: 'announce'
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile 'com.android.support:cardview-v7:21.0.+'
    }
    

    您在您的项目的build.gradle的依赖应该是这样的,由IDE生成的评论,告诉你不要把你的应用程序的依赖关系在这里:

    Your dependencies in your Project build.gradle should look like this, the comment is generated by the IDE and tells you not to put your app dependencies here :

     dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    

    它们移动到/app/build.gradle文件,我修改您的文件一点,所以它是最新的,以编译工具等。目前最新版本,您可能必须从你的SDK管理器下载其中的一些,如果你不已经有:

    Move them to the /app/build.gradle file, and I modified your file a little so its up to date to the currently newest version of buildTools etc. You might have to download some of them from your SDK Manager if you dont already have :

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 22
        buildToolsVersion "22.0.1"
    
    defaultConfig {
        applicationId "your.package.name"
        minSdkVersion 8
        targetSdkVersion 22
    }
    
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
       }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:22.0.0'
        compile 'com.android.support:support-v4:+'
        compile files('libs/FlurryAnalytics_3.3.0.jar')
        compile files('libs/heyzap-ads-sdk.jar')
        compile files('libs/HomeBaseSDK2.2.jar')
        compile files('libs/placed-persistent-sdk-1.10.jar')
        compile files('libs/revmob-6.7.0.jar')
     }
    

    这篇关于而错误的项目移植到Android工作室?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆