2016-05-03 2 views
0

Ich versuche, Beispiel physischen Web-android-Client von here zu bauen. Nachdem in Android Studio importieren, bin vor mir diesen Fehler:Physische Web-android-Client bauen Fehler: com.android.dx.cf.iface.ParseException

Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION: 
Unknown source file : com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000) 
Unknown source file : at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472) 
Unknown source file : at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406) 
Unknown source file : at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388) 
Unknown source file : at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251) 
Unknown source file : at com.android.dx.command.dexer.Main.processClass(Main.java:704) 
Unknown source file : at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) 
Unknown source file : at com.android.dx.command.dexer.Main.access$300(Main.java:83) 
Unknown source file : at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602) 
Unknown source file : at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) 
Unknown source file : at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) 
Unknown source file : at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) 
Unknown source file : at com.android.dx.command.dexer.Main.processOne(Main.java:632) 
Unknown source file : at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510) 
Unknown source file : at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280) 
Unknown source file : at com.android.dx.command.dexer.Main.run(Main.java:246) 
Unknown source file : at com.android.dx.command.dexer.Main.main(Main.java:215) 
Unknown source file : at com.android.dx.command.Main.main(Main.java:106) 
Unknown source file : ...while parsing org/physical_web/collection/BitmapRequest$RequestCallback.class 
Unknown source file : 1 error; aborting 

:app:preDexDebug FAILED 

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':app:preDexDebug'. 
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_72.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1 

ich nichts im Code geändert habe, weiß also nicht, warum dieser Fehler. Bitte helfen Sie.

Wenn ich ändern, um die JDK-Version 1,8 bis 1,7, die Fehler Änderungen an:

:app:dexDebug 
UNEXPECTED TOP-LEVEL EXCEPTION: 
com.android.dex.DexException: Multiple dex files define Lorg/physical_web/collection/Request$RequestCallback; 
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) 
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) 
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) 
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) 
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) 
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) 
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303) 
    at com.android.dx.command.dexer.Main.run(Main.java:246) 
    at com.android.dx.command.dexer.Main.main(Main.java:215) 
    at com.android.dx.command.Main.main(Main.java:106) 
Error:Execution failed for task ':app:dexDebug'. 
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2 

Update:

Hier sind alle meine gradle Dateien:

für app Modul:

apply plugin: 'com.android.application' 
    apply plugin: 'checkstyle' 
    apply plugin: 'findbugs' 
    apply plugin: 'pmd' 

    android { 
    compileSdkVersion 21 
    buildToolsVersion "21.1.2" 

    defaultConfig { 
     applicationId "physical_web.org.physicalweb" 
     minSdkVersion 19 
     targetSdkVersion 21 
     versionCode 15 
     versionName "0.1.856" 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_7 
     targetCompatibility JavaVersion.VERSION_1_7 
    } 

    if(new File("signing.properties").exists()) { 
     Properties signingProperties = new Properties() 
     signingProperties.load(new FileInputStream(new File('signing.properties'))) 

     signingConfigs { 
      release { 
       storeFile new File(signingProperties['storeFile']) 
       storePassword signingProperties['storePassword'] 
       keyAlias signingProperties['keyAlias'] 
       keyPassword signingProperties['keyPassword'] 
      } 
     } 

     buildTypes { 
      release { 
       signingConfig signingConfigs.release 
      } 
     } 
    } 

    lintOptions { 
     // We'll get to fixing the icon later 
     disable 'IconLauncherShape', 'IconDensities', 'IconMissingDensityFolder', 'LongLogTag' 
     // Travis requires an older api at the moment 
     disable 'OldTargetApi' 
    } 
} 

repositories { 
    flatDir { 
     dirs 'libs' 
    } 
} 

dependencies { 
    compile(project(':libs')) { 
     exclude group: 'org.json', module: 'json' 
    } 

    compile 'com.android.volley:[email protected]' 
    compile 'org.uribeacon:[email protected]' 

    compile 'com.android.support:appcompat-v7:22.1.1' 
} 

task checkstyle(type: Checkstyle) { 
    configProperties.checkstyleSuppressionsPath = new File(rootDir, "app/config/checkstyle/suppressions.xml").absolutePath 
    source 'src' 
    include '**/*.java' 
    exclude '**/gen/**' 
    classpath = files() 
} 

task findbugs(type: FindBugs, dependsOn: assembleDebug) { 
    ignoreFailures = false 
    effort = "max" 
    reportLevel = "high" 
    classes = files("${project.rootDir}/app/build/intermediates/classes") 
    excludeFilter = file("${project.rootDir}/app/config/findbugs/exclude-filter.xml") 

    source 'src' 
    include '**/*.java' 
    exclude '**/gen/**' 

    reports { 
     xml.enabled = false 
     html.enabled = true 
     xml { 
      destination "$project.buildDir/reports/findbugs/findbugs.xml" 
     } 
     html { 
      destination "$project.buildDir/reports/findbugs/findbugs.html" 
     } 
    } 

    classpath = files() 
} 

task pmd(type: Pmd, dependsOn: assembleDebug) { 
    ignoreFailures = false 
    ruleSetFiles = files("${project.rootDir}/app/config/pmd/pmd-ruleset.xml") 
    ruleSets = [] 

    source 'src' 
    include '**/*.java' 
    exclude '**/gen/**' 

    reports { 
     xml.enabled = false 
     html.enabled = true 
     xml { 
      destination "$project.buildDir/reports/pmd/pmd.xml" 
     } 
     html { 
      destination "$project.buildDir/reports/pmd/pmd.html" 
     } 
    } 
} 

check.dependsOn 'checkstyle', 'findbugs', 'lint', 'pmd' 

settings.gradle:

include ':app', ':libs' 

project(':libs').projectDir = new File('../../java/libs') 

für 'Libs' Projekt:

plugins { 
    id 'checkstyle' 
    id 'findbugs' 
    id 'java' 
    id 'pmd' 
} 

repositories { 
    jcenter() 
} 

sourceSets { 
    integrationTest { 
     java { 
      compileClasspath += main.output + test.output 
      runtimeClasspath += main.output + test.output 
      srcDir file('src/integrationTest/java') 
     } 
    } 
} 

configurations { 
    integrationTestCompile.extendsFrom testCompile 
    integrationTestRuntime.extendsFrom testRuntime 
} 

gradle.projectsEvaluated { 
    tasks.withType(JavaCompile) { 
     options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" 
    } 
} 

dependencies { 
    compile 'org.json:json:20140107' 
    testCompile 'junit:junit:4.11' 
    testCompile 'org.skyscreamer:jsonassert:1.2.3' 
} 

task integrationTest(type: Test) { 
    testClassesDir = sourceSets.integrationTest.output.classesDir 
    classpath = sourceSets.integrationTest.runtimeClasspath 
    outputs.upToDateWhen { false } 
} 

findbugsMain { 
    ignoreFailures = false 
    effort = "max" 
    reportLevel = "low" 
    reports { 
     xml.enabled = false 
     html.enabled = true 
    } 
} 

findbugsTest { 
    ignoreFailures = false 
    effort = "max" 
    reportLevel = "low" 
    reports { 
     xml.enabled = false 
     html.enabled = true 
    } 
} 

findbugs { 
    reportsDir = new File(buildDir, "reports/findbugs") 
    excludeFilter = new File(projectDir, "config/findbugs/exclude-filter.xml") 
} 

checkstyle { 
    configProperties.checkstyleSuppressionsPath = 
      new File(projectDir, "config/checkstyle/suppressions.xml") 
} 

pmdMain { 
    reports { 
     xml.enabled = false 
     html.enabled = true 
    } 
} 

pmd { 
    ignoreFailures = false 
    ruleSetFiles = files(new File(projectDir, "config/pmd/pmd-ruleset.xml")) 
    ruleSets = [] 
    reportsDir = new File(buildDir, "reports/findbugs") 
} 

javadoc { 
    source = sourceSets.main.java 
    classpath = sourceSets.main.runtimeClasspath 
} 

tasks.withType(Test) { 
    reports.html.destination = file("${reporting.baseDir}/${name}") 
} 

integrationTest.dependsOn assemble 
+0

PLZ Aktie Gradle-Datei .... !!! –

+0

@ExceptionLover: Alle meine Gradle-Dateien hinzugefügt – Yashasvi

Antwort

1

ich gelöst es nach 2-3 Stunden.

Dieses Projekt benötigt JDK 1.7. Auf JDK 1.8 gibt es das Unknown source file : com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000) .

Warum bekam ich die com.android.dex.DexException: Multiple dex files define Lorg/physical_web/collection/Request$RequestCallback; Fehler nach dem Ändern der jdk auf 1,7 ist, weil ich vergessen habe, das Projekt zu reinigen, bevor Sie es erneut ausführen. So gab es mehrere Dex-Dateien, eine, die mit jdk 1.8 generiert wurde und eine, die mit jdk 1.7 generiert wurde.

+0

gute Arbeit ........... –