I'm having major problems with building my project.
My project is getting built in Android Studio, and the directory is like so:
root
-project
--build
--libs
--src
---java
----com
-----company.project
------<All this projects source>
-projectutils
--build
--src
---main
----java
-----com.company.utils
------<All this projects source>
"project" is the main app, and it includes projectutils as a dependency. It uses Gradle to build, and I've added the correct includes to the root settings.gradle, and the correct dependencies to project.
Here is my settings.gradle in the root of my project:
include ':project', ':projectutils'
Here is my build.gradle for my project:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'com.company.project'
minSdkVersion 15
targetSdkVersion 17
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile files('libs/android-support-v4.jar')
compile files('libs/commons-validator-1.4.0.jar')
compile 'com.viewpagerindicator:library:2.4.1@aar'
compile 'joda-time:joda-time:2.3'
compile project(':projectutils')
}
No matter what I do, it always gives the error Error:(4, 34) error: package com.company.utils.database does not exist, even though I've added the correct dependency and the Android auto-complete can see and parse the import command, so obviously Android studio is able to see it correctly. There are a ton more errors, but they are all fundamentally the same: It can't seem to find com.company.utils and I have no idea what else I need to do.
I've spent all day trying to get this thing set up just to get it running and this is the biggest brick wall so far. I have literally no idea what I could be missing to cause these errors. I've fixed a bunch of similar errors with Facebook and Kumulos but this one won't work no matter what I try. Could anyone give me some pointers?
I usually just start restarting and rebuilding things until something "takes". If you have Android Studio start with "Sync Project with Gradle Files" (there should be an icon for it in the ribbon by default). Then try rebuilding the project. Then try closing and checking the Windows Task Manager to make sure studio64.exe has completely closed and the process has stopped running, then restart Android Studio. Also restart the device you're using for testing. That's worked for me every time I encountered an error that shouldn't be happening.
I have this problem just now, the reason is because I accidentally create the class by menu item New -> File instead of New -> Java Class.
I insert file name without .java extension, since there is a dialog to allow me to choose Java, so I don't realize my mistake at this point:
I add package
header code manually, and all seems works fine (able ctrl+click to inspect), but it keep showing "cannot find symbol" for that class when trying to build.
The issue is because this method create file name without .java extension.
If you get similar error, try to check the file name extension.
Change the
compile 'com.google.android.gms:play-services:6.5.87'
by
compile 'com.google.android.gms:play-services:6.1.71'
in dependencies in gradle file {build.gradle file}.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With