Android导入项目失败

时间:2017-06-21 13:36:56

标签: java android android-studio

我正在尝试在Android Studio中导入项目但是如果失败

以下是该项目:

project

我收到此错误:

> C:\xampp\htdocs\freedom\Android-IP-Camera-master\spydroid-ipcamera-master\app\build\intermediates\res\merged\debug\values-ldltr-v21\values-ldltr-v21.xml
> Error:(3) Error retrieving parent for item: No resource found that
> matches the given name 'android:Widget.Material.Spinner.Underlined'.
> Error:(3) Error retrieving parent for item: No resource found that
> matches the given name 'android:Widget.Material.Spinner.Underlined'.
> C:\xampp\htdocs\freedom\Android-IP-Camera-master\spydroid-ipcamera-master\app\build\intermediates\res\merged\debug\values-v21\values-v21.xml
> Error:(17) Error retrieving parent for item: No resource found that
> matches the given name 'android:TextAppearance.Material.Inverse'.

修改

以下是项目的gradle文件。

build.gradle(模块:app):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "net.majorkernelpanic.spydroid"
        minSdkVersion 14
        targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.google.android.gms:play-services:+'
    compile files('libs/acra-4.4.0.jar')
    compile files('libs/GoogleAdMobAdsSdk-6.1.0.jar')
    compile files('libs/sc-light-jdk15on-1.47.0.2.jar')
    compile files('libs/scpkix-jdk15on-1.47.0.2.jar')
    compile files('libs/scprov-jdk15on-1.47.0.2.jar')
}

build.gradle(项目:spydroid-ipcamera-master):

// 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:2.3.3'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

2 个答案:

答案 0 :(得分:0)

首先改变

compile files('libs/acra-4.4.0.jar')
compile files('libs/GoogleAdMobAdsSdk-6.1.0.jar')
compile files('libs/sc-light-jdk15on-1.47.0.2.jar')
compile files('libs/scpkix-jdk15on-1.47.0.2.jar')
compile files('libs/scprov-jdk15on-1.47.0.2.jar')

compile fileTree(include: ['*.jar'], dir: 'libs')

第二次尝试使用app战斗库,导致一些资源丢失

compile 'com.android.support:appcompat-v7:25.4.0'

或者你可以编译你的compileSdkVersion&& targetSdkVersion到21 +

答案 1 :(得分:0)

我导入了相关项目,并在build.gradle中查找了一些内容,以及AS推荐的最新版本。
用此更改您的build.gradle(模块:应用)并尝试:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0"

defaultConfig {
    applicationId "net.majorkernelpanic.spydroid"
    minSdkVersion 14
    targetSdkVersion 19
}

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
       }
    }
}
dependencies {
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.google.android.gms:play-services:11.0.0'
    compile files('libs/acra-4.4.0.jar')
    compile files('libs/GoogleAdMobAdsSdk-6.1.0.jar')
    compile files('libs/sc-light-jdk15on-1.47.0.2.jar')
    compile files('libs/scpkix-jdk15on-1.47.0.2.jar')
    compile files('libs/scprov-jdk15on-1.47.0.2.jar')
}

在我的案例中,项目同步并完美运行。

更新:
我要补充一点,您还必须使用新的apache HttpClient更改已弃用的HttpURLConnection
为此,请在build.gradle(模块:应用)中添加以下代码:

useLibrary 'org.apache.http.legacy'