初用Android studio出现的问题

来源:互联网 发布:怎样用java做网站 编辑:程序博客网 时间:2024/05/16 01:47

android studio安装后第一次打开卡在fetching Android sdk compoment information
解决办法:
找到android studio 安装目录下bin目录中(D:\Android\Android Studio\bin)的idea.properties文件
,在文件末尾处添加disable.android.first.run=true
然后再打开android studio就不会再去fetch了 ,再手动设置android sdk目录。下次打开android 
studio就不会再出现了



环境变量中注意两个jdk的冲突



1. If you see a message saying 'The path ... does not refer to an Android SDK. Android 
Studio will use its default SDK instead,' click OK.
2. If you see a message saying 'Failed to find Build Tools revision 21.1.2', open your 
build.gradle file and replace this line with the version in Android Studio (Check your 
build tools version in the SDK Manager)
buildToolsVersion "21.1.2"
3. If you see a message saying 'Failed to sync the Gradle project .... Fix plugin version 
and re-import project,' simply click the link to agree.
4. If you see a warning that says 'Language level changes will take effect on project 
reload. Would you like to reload project ... now?', click Yes.


//错误信息
1.Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find any version that matches com.android.support:appcompat-v7:22.+.
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/support/appcompat-v7/maven-metadata.xml
         https://jcenter.bintray.com/com/android/support/appcompat-v7/
         file:/D:/Android/sdk/extras/android/m2repository/com/android/support/appcompat-

v7/maven-metadata.xml
         file:/D:/Android/sdk/extras/google/m2repository/com/android/support/appcompat-

v7/maven-metadata.xml
         file:/D:/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/
     Required by:
         MyApplication:app:unspecified


2.Error:Failed to find: com.android.support:appcompat-v7:22.+
<a href="openFile">Open File</a><br><a href="open.dependency.in.project.structure">Open in 

Project Structure dialog</a>

//解决方法
//app 的build.gradle里代码如下
apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion '21.1.2'
  ///要和SDK  Manager里的buildToolsVersion一致

    defaultConfig {
        applicationId "com.example.dongzhe.zlqhapp"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-
rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    productFlavors {
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/commons-logging-1.1.1.jar')
    compile files('libs/commons-codec-1.10.jar')

    compile 'com.android.support:appcompat-v7:21.0.3'
    ///要和sdk/extras/android/m2repository/com/android/support/appcompat-v7中的版本一致

}

0 0