Android studio项目未配置

时间:2017-01-04 12:06:03

标签: android

今天,我开始了我的android工作室,所有都没有配置。类显示了很多错误。这是android studio在我尝试运行应用程序时显示的错误:

错误:java.lang.NullPointerException(无错误消息)

enter image description here

这是我的傻瓜:

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 23
        buildToolsVersion "25.0.1"
        defaultConfig {
            applicationId "com.example.garcia.coachtrain"
            minSdkVersion 21
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_6
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:23.4.0'
        compile 'com.squareup.okhttp3:okhttp:3.3.0'
        compile 'com.roomorama:caldroid:3.0.1'
        compile 'com.android.support:design:23.0.1'
        testCompile 'junit:junit:4.12'
    }

i add the new gradle:



  apply plugin: 'com.android.application'

    android {
        compileSdkVersion 25
        buildToolsVersion '25.0.1'
        defaultConfig {
            applicationId "com.example.garcia.coachtrain"
            minSdkVersion 21
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:25.1.0'
        compile 'com.squareup.okhttp3:okhttp:3.3.0'
        compile 'com.roomorama:caldroid:3.0.1'
        compile 'com.android.support:design:25.0.1'
        testCompile 'junit:junit:4.12'
    }

如果我把这个sdk版本,编译'com.roomorama:caldroid:3.0.1'不起作用。 java类没有找到caldroid。

由于

3 个答案:

答案 0 :(得分:1)

尝试将sdk更新为最新版本,因为您的编译sdk版本和构建工具版本不同。

Bundle bundle = this.getIntent().getExtras();

if(bundle != null) {
   hashMap = bundle.getSerializable("HashMap");
}

答案 1 :(得分:1)

我解决了这个问题:

文件菜单 - >无效的缓存/重启

在警告窗口中 - >选择invalidate / restart

这解决了我的问题,我保留了这个gradle配置:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.1'
    defaultConfig {
        applicationId "com.example.garcia.coachtrain"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.squareup.okhttp3:okhttp:3.3.0'
    compile 'com.roomorama:caldroid:3.0.1'
    compile 'com.android.support:design:23.0.1'
    testCompile 'junit:junit:4.12'
}

答案 2 :(得分:0)

清理项目,然后重启android studio。