Reputation: 41
I've been working on a personal project, but in the past few days builds haven't been updating my R.java. I'm not sure what could be causing it. I haven't seen any syntax errors in the XML resources, but the the one time it did work was when I generated it manually a couple of days ago (app:generateDebugResources
), and at the time the only resource in the project was under res/raw, an HTML document. Since then I've written the bulk of what I need for the admittedly minimal functionality I'm implementing, and removed R.java in working to solve the problem. The only remaining thing Android Studio seems to be interested in complaining about is the unrecognized symbol 'R'
. I feel like I've hit a wall; I'll be posting my XML as well as my build configuration and settings. I'm open to any suggestions as to why Gradle might be failing to package my resources, as well as constructive critique. In-process building is disabled.
settings.gradle:
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>
Upvotes: 1
Views: 90
Reputation: 41
Problem solved! I just ran the AAPT manually and checked the output; it led me straight to the one error I'd made in my XML resources. Gradle's tasks now generate R.java without issue.
Upvotes: 1