I'm trying to use the Hugo library developed by Jake Wharton.
I added the statement:
compile 'com.jakewharton.hugo:hugo-plugin:1.2.1'
to my dependencies in my build.gradle file at the app level.
Then when I try to annotate with #DebugLog on my methods, it appears in red, as if the IDE doesn't recognize it.
I tried typing in an import statement like:
import com.jakewharton.hugo;
but the jakewharton part of the import statement appears in red, meaning it doesn't see it.
I've googled, and found references like:
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
I'm not sure what the difference between compile and classpath is.
Also, I see a reference to:
apply plugin: 'hugo'
Where should that go?
As you can see I'm totally lost. Any ideas on how to make this work is greatly appreaciated.
I'm not sure you are referencing the app module build.gradle or the project level build.gradle.
But eventually, I put it all in the app module build.grade and it worked for me. This is how the file looked like:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.hugo'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.app_name"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
}
A correct configuration would look like this in your build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.hugo'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
}
}
dependencies {
// Other dependencies
}
There is no need to add Hugo to the second dependencies section, this is done for you by the plugin.
I had had the same problem, but realized I had apply plugin: 'com.android.application' typed twice. Once I deleted the extra reference, placing the Jake Wharton stuff at the top of build.gradle (app), it removed the red lines.
Related
This question already has answers here:
Android Studio 3.1 "Run" not compiling code
(5 answers)
Closed 4 years ago.
I have a weird problem with Android Studio. When I Run my app there are no gradlebuild and etc. just installing app and launch activity which means nothing what I changed in the code will be changed in my apk.
Have you any idea why is this happening?
project level gradle:
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
classpath 'com.google.gms:google-services:3.2.0'
classpath "io.realm:realm-gradle-plugin:5.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app level gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
android {
compileSdkVersion 26
defaultConfig {
applicationId ""
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
realm {
syncEnabled = true;
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
}
apply plugin: 'com.google.gms.google-services'
You have to fix the Run process in Android Studio.
Look at your main toolbar and find this box:
Click the box and select Edit Configurations....
Make sure the window has the following items in Before launch section:
Gradle-aware Make
Instant App Provision
Click OK.
Run your app.
Try this: File menu -> Invalidate Caches/ Restart. I think it will resolve your problem.
There's been an issue in the 3.1.0 build tools upgrade of Android Studio. Follow these steps to resolve it.
Select Run and click Edit Configurations
Make sure, Gradle-aware Make is Added in TaskList or not. If not then:
click +
select Gradle-aware Make
Leave the task empty and select OK
NOTE: Make sure Gradle-aware Make is before Instant App Provision
Try to following instruction it will surely help you. I already face same problem before couple of month.
* Update ADB in your Android Studio.
* Uninstall application.
* Restart adb start-server.
* Restart you testing device.
I am completely new to realm. I want to use realm db in my android project. I have gone through the official Realm documentation. I need to set up realm in my android project. For that I have added the gradle dependancy as
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:0.88.2"
}
}
apply plugin: 'realm-android'
This is what they have given in documentation. But this doesn't work for me. It gives error saying Plugin with id 'realm-android' not found.
This is my build.gradle file
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.db.realmsample"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:0.88.2"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
}
Is my configuration correct?
Move the buildscript to your main build.gradle file (Project) , it shouldn't be there in build.gradle (module:app)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:<realm version>"
}
}
This should go to main build.gradle
First of all copy the class path dependency to build.gradle file(Project):-
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:1.2.0"
}
}
Finally, copy and paste the following code on top of build.gradle(App) :-
apply plugin: 'realm-android'
Note:- The version 1.2.0 is subjected to change on future releases.For more please check https://realm.io/docs/java/latest/
Prerequisites
Android Studio version 1.5.1 or higher
JDK version 7.0 or higher
A recent version of the Android SDK
Android API Level 9 or higher (Android 2.3 and above)
Step 1: Add the class path dependency to the project level build.gradle file.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:4.1.1"
}
}
Step 2: Apply the realm-android plugin to the top of the application level build.gradle file.
apply plugin: 'realm-android'
Step 3: Gradle sync
For the official complete installation guide. Please see the following link.
https://realm.io/docs/java/latest/#installation
The method I used is
` dependencies
{
classpath 'com.android.tools.build:gradle:3.0.0'
classpath "io.realm:realm-gradle-plugin:3.1.4"
}`
in your main build gradle file
then add
apply plugin: 'realm-android'
and
compile 'io.realm:android-adapters:2.0.0'
in your app's build gradle
this link to bintray will give you the latest build
https://bintray.com/realm/maven/realm-android-library/3.4.0#files/io%2Frealm%2Frealm-android-library%2F3.4.0
I know there are similar questions like this but i'm new in android development and i need to learn how to import an example defining repositories and dependencies in the build.gradle project file.
After several tries i can't figure out which is the right way...
The example is this one https://github.com/neokree/MaterialNavigationDrawer
When i load the project in android studio i get an error "Configuration with name 'default' not found.", and it's ok.. i know that i have to modify the build.grandle file
repositories {
mavenCentral()
}
dependencies {
compile 'it.neokree:MaterialNavigationDrawer:1.3.3'
}
But where i have to add/replace these rows? In the buildscript area? in the allprojects? i get "Gradle DSL method not found: 'compile()'" error or fix plugin version alert if i try to change something.
original build.grandle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
}
Your problem is in setting.gradle file in the MaterialNavigationDrawer project. As you can see
include ':app', ':MaterialNavigationDrawerModule'
it requires MaterialNavigationDrawerModule project to build. Go to New > Import Module and import MaterialNavigationDrawerModule.
Update build.gradle in MaterialNavigationDrawer\app to
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "it.neokree.materialnavigationdrawer"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
buildTypes {
release {
//runProguard false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
compile project(':MaterialNavigationDrawerModule')
}
Update build.gradle in MaterialNavigationDrawer\MaterialNavigationDrawerModule to
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName 'dev'
}
buildTypes {
release {
}
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.balysv:material-ripple:1.0.1'
}
In MainActivity i deleted missing import
and rewrite Intent
to
Now it's working.
I'm trying to use MaterialDialog in my project, but this library doesn't support my Right to Left language and I must edit that. After downloading the project and importing it into current project I get this error when building my project:
Error:(2, 0) Plugin with id 'com.novoda.bintray-release' not found.
After many searches on the web I find this link to resolve this. But that doesn't work for my project:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
/* I'm adding this below line */
classpath 'com.novoda:bintray-release:0.2.7'
}
}
allprojects {
repositories {
jcenter()
}
}
If you have downloaded the actual library and have imported it to Android studio and modified it then you want to add the dependency in your gradle.build (Module:app). The code you are showing is from gradle.build (Project: NameOfYourProject) so I would delete that line you added there.
Go to the build.gradle (Module:app) file which will look something like shown below and add the library as shown.
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.yourappname"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-project.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile project(':nameOfTheLibrary')
}
Add
dependencies {
compile 'com.afollestad:material-dialogs:0.7.7.0'
}
and press the sync button.
Gradle no longer finds dependencies declared in the build.gradle. Everything was working fine and today when I open Android Studio I get an error :
Error:Failed to find: com.readystatesoftware.systembartint:systembartint:1.0.3
The library referenced is SystemBarTint. I had the library work previously using the same build.gradle file but now it no longer works.
My app/build.gradle looks like this :
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.adnan.systembartintdemo"
minSdkVersion 19
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
}
My root/build.gradle looks like this :
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
Any ideas what I am doing wrong here? Thanks !
Edit : Tried importing a project which I work on daily at my work, it fails to find any dependencies in that project either. Tried re installing Android Studio, still the same error
Ok finally got this fixed.The problem was weird, for some reason it was trying to pick up a local offline copy of the dependency, I went to Settings -> Compiler -> Gradle -> Enabled offline Work and disabled it again. Save and Apply changes.
And now it works !