在属于Library项目的类中,我调用:
webview.loadUrl("file:///android_asset/info.html", null);
Run Code Online (Sandbox Code Playgroud)
不幸的是,这只有在我将文件info.html 复制到Application的项目资产文件夹中时才有效.
有没有办法告诉Android库代码:"在库的资源文件夹中查找此文件,而不是在应用程序的资源文件夹中"?
到目前为止,我已将以下内容添加到"build.gradle"的末尾
task copyFiles(type: Copy)
copyFiles {
description = 'Copies html5 files from the common library...'
from '../../www'
into 'assets/www'
include('**/*')
}
Run Code Online (Sandbox Code Playgroud)
现在我只需要一些帮助来了解如何在每次(编译)android源代码之前执行此任务.我可以从命令行手动运行复制任务,但我喜欢在android studio中单击"运行"时运行它.
在下面的建议的帮助下,我补充说
clean.dependsOn copyFiles
clean.mustRunAfter copyFiles
Run Code Online (Sandbox Code Playgroud)
通过这个添加,我可以通过重建 - >运行来运行我的复制任务.它总比没有好,但跳过重建步骤会更好.
这是我使用android studio的整个build.gradle.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile files('/libs/acra-4.3.0.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17"
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src','libs']
resources.srcDirs = ['src']
aidl.srcDirs = …Run Code Online (Sandbox Code Playgroud) 我在eclipse 中的res/raw文件夹中保存了一个文本文件.我在这里显示该文件的内容:
{
"Categories": {
"Category": [
{
"cat_id": "3",
"cat_name": "test"
},
{
"cat_id": "4",
"cat_name": "test1"
},
{
"cat_id": "5",
"cat_name": "test2"
},
{
"cat_id": "6",
"cat_name": "test3"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
我想解析这个JSON数组.我怎样才能做到这一点?
有人可以帮帮我吗?
提前致谢.