资源程序集失败



我一直在做一个个人项目,但在过去的几天里,构建一直没有更新我的R.java。我不确定是什么原因导致了它。我没有在XML资源中看到任何语法错误,但它做的一次工作是几天前手动生成的(app:generateDebugResources),当时项目中唯一的资源在res/raw下,HTML文档。从那以后,我已经为我正在实现的公认的最小功能编写了我需要的大部分内容,并在解决问题的过程中删除了R.java。安卓工作室似乎唯一有兴趣抱怨的是unrecognized symbol 'R'。我感觉自己撞到了墙上;我将发布我的XML以及我的构建配置和设置。我愿意接受任何关于Gradle为什么没有打包我的资源的建议,以及建设性的批评。进程中的生成已禁用。

settings.grade:

include 'app'
//include 'nanohttpd'
project(':app').projectDir = new File('app')
//project(':nanohttpd').projectDir = new File('nanohttpd')

build.gradle:

apply plugin: 'java'
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
    }
}
project(':app') {
    dependencies {
    }
}
/*
project(':nanohttpd') {
    dependencies {
    }
}
*/

:app:build.gradle:

apply plugin: 'com.android.application'
repositories {
    mavenCentral()
}
android {
    compileSdkVersion 16
    buildToolsVersion "24.0.1"
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        //compile project(':nanohttpd')
        compile group: 'commons-codec', 
                name: 'commons-codec', version: '1.10'
        compile group: 'org.nanohttpd', 
                name: 'nanohttpd', version: '2.3.0'
    }
    sourceSets {
        main {
            java {
                srcDir 'src/java'
            }
            resources {
                srcDir 'src/res'
            }
            manifest {
                srcFile 'src/android-manifest.xml'
            }
        }
    }
   defaultConfig {
       minSdkVersion 16
       targetSdkVersion 16
       applicationId "site.wyrxce.httpclip"
   }
   buildTypes {
       release {
           minifyEnabled true
           //signingConfig signingConfigs.release
           proguardFile getDefaultProguardFile('proguard-android.txt')
       }
       debug {
           initWith release
           applicationIdSuffix ".debug"
           signingConfig null
           debuggable true
       }
   }
}

src/res/xml/prefs_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:key="PreferenceScreen_main">
    <SwitchPreference
        android:key="SwitchPreference_runServer"
        android:defaultValue="false"/>
    <EditTextPreference
        android:key="EditTextPreference_hostPort"
        android:defaultValue="3939"
        android:numeric="integer"
        android:maxLength="5"/>
</PreferenceScreen>

src/res/values/strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="bad_request">Unrecognized input</string>
    <string name="bad_passwd">Invalid credentials</string>
    <string name="internal_err">Internal server error</string>
    <string name="clipboard_desc">HTTPClip Input</string>
    <string name="toasttext_serverstarted">
            HTTPClip service now listening</string>
    <string name="toasttext_serverstopped">
            HTTPClip Service stopped</string>
    <string name="title_switchpreference_runserver">
            Run HTTPClip service</string>"
    <string name="title_edittextpreference_hostport">Host Port</string>
    <string name="summary_edittextpreference_hostport">
            Listening port for HTTP Daemon</string>
</resources>

问题解决了!我只是手动运行AAPT并检查输出;它让我直接看到了我在XML资源中犯的一个错误。Gradle的任务现在可以毫无问题地生成R.java。

相关内容

最新更新