我在尝试创建一个显示带有WebView的DialogFragment的库时遇到了一些问题。此项目已设置,因此可用作Appcelerator应用程序的Titanium模块。
当我在原生Android示例应用中使用我的库时,它工作正常。但是当我在我的Titanium应用程序中使用它时,我收到以下错误:
06-14 11:58:57.287: E/AndroidRuntime(25142): FATAL EXCEPTION: main
06-14 11:58:57.287: E/AndroidRuntime(25142): Process: be.iminds.livinglabs.wappr, PID: 25142
06-14 11:58:57.287: E/AndroidRuntime(25142): android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v4/abc_ab_share_pack_mtrl_alpha.9.png from xml type layout resource ID #0x7f020000
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2821)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2776)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.content.res.Resources.getLayout(Resources.java:1165)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
06-14 11:58:57.287: E/AndroidRuntime(25142): at be.iminds.mupets_client_android.esm.EsmDialogFragment.onCreateView(EsmDialogFragment.java:61)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.app.Fragment.performCreateView(Fragment.java:2220)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.app.BackStackRecord.run(BackStackRecord.java:793)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.app.FragmentManagerImpl$1.run(FragmentManager.java:482)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.os.Handler.handleCallback(Handler.java:739)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.os.Handler.dispatchMessage(Handler.java:95)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.os.Looper.loop(Looper.java:148)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.app.ActivityThread.main(ActivityThread.java:5417)
06-14 11:58:57.287: E/AndroidRuntime(25142): at java.lang.reflect.Method.invoke(Native Method)
06-14 11:58:57.287: E/AndroidRuntime(25142): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
06-14 11:58:57.287: E/AndroidRuntime(25142): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-14 11:58:57.287: E/AndroidRuntime(25142): Caused by: java.io.FileNotFoundException: Corrupt XML binary file
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.content.res.AssetManager.openXmlAssetNative(Native Method)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:485)
06-14 11:58:57.287: E/AndroidRuntime(25142): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2803)
06-14 11:58:57.287: E/AndroidRuntime(25142): ... 18 more
所以我自然认为有一些缺失的依赖项,或者可能在应用程序中编译了有问题的文件。但是,当我爆炸编译的APK时,提到的文件正好在系统所说的无法找到它的位置。
有人能帮助我吗?几个星期以来,我一直坚持这个问题。
THX!
编辑:
这是我的build.gradle:
apply plugin: 'com.android.library'
def GROUP_ID = 'be.iminds.mupets'
def ARTIFACT_ID = 'mupets'
def VERSION = "1.0.2"
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 3
versionName "1.0.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
encoding = 'UTF-8'
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'LICENSE.txt'
}
lintOptions {
warning 'InvalidPackage'
abortOnError false
}
}
android.libraryVariants.all { variant ->
if (variant.buildType.isDebuggable()) {
return; // Skip debug builds.
}
task("javadoc${variant.name.capitalize()}", type: Javadoc) {
description "Generates Javadoc for $variant.name."
source = variant.javaCompile.source
// Add all of your dependencies and android jars to the classpath
classpath += files(variant.javaCompile.classpath.files)
classpath += files(android.getBootClasspath())
exclude '**/BuildConfig.java'
exclude '**/R.java'
options.links("http://docs.oracle.com/javase/7/docs/api/")
options.linksOffline("http://d.android.com/reference", "${android.sdkDirectory}/docs/reference")
options.charSet("utf-8")
}
task("bundleJavadoc${variant.name.capitalize()}", type: Jar) {
description "Bundles Javadoc into zip for $variant.name."
classifier = "javadoc"
from tasks["javadoc${variant.name.capitalize()}"]
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.google.code.gson:gson:2.4'
compile 'com.cookpad.puree:puree:4.1.1'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
}
task androidJar(type: Jar) {
from 'build/intermediates/classes/release'
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
task androidJavadocJar(type: Jar) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
artifacts {
archives androidJar
archives androidSourcesJar
archives androidJavadocJar
}
task deployJavadoc(type: Exec) {
workingDir '../'
executable "./deploy_javadoc.sh"
args VERSION
}