Can not find symbol volley - android

import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import code.studio.v.R;
import code.studio.v.volley.RequestQueue;
Android studio is showing an error . Can not resolve symbol volley. I have cloned volley and added it as a module. My package name is code.studio.v
The following is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "code.studio.v"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
}
the following is settings.gradle file .
include ':app', ':volley'

remove module dependencies and add library dependencies..using following steps
Right Click on project - Module Setting
Go to dependencies- click plus(+) symbol
type volley and enter.. select the4thfloor dependencies
Finally sync gradle and run

If you have imported volley library as a separate module then you have to add dependency compile project(':yourVolleyModule') into your app's build.gradle. Now, Sync your gradle and i hope it will work

Related

Error trying to import Gradle Project to Android Studio existing project

I am trying to import 3 Gradle Projects I used in all my apps with utilities to a new project.
I create the new project and then File -> Project Structure -> + -> Import Gradle Project
Then I click Finish but those 3 projects do not appear in the modules list
No error has appeared yet. But when I click Ok there I do got 4 IDE fatal errors:
1/4
Element: class org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl because: different providers: SingleRootFileViewProvider{myVirtualFile=file://F:/development/workspaces/Orchestram/settings.gradle, content=VirtualFileContent{size=16}}(2177d6ca); SingleRootFileViewProvider{myVirtualFile=file://F:/development/workspaces/Orchestram/settings.gradle, content=VirtualFileContent{size=16}}(16a77aa0)
2/4
Element: class com.intellij.psi.impl.compiled.ClsFileImpl because: file://F:/development/workspaces/Orchestram/app/callRemoteService/build/intermediates/classes/debug/com/qbitera/CallRemoteService/R.class is invalid
3/4
Element: class org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl because: different providers: SingleRootFileViewProvider{myVirtualFile=file://F:/development/workspaces/Orchestram/settings.gradle, content=VirtualFileContent{size=16}}(344f03e4); SingleRootFileViewProvider{myVirtualFile=file://F:/development/workspaces/Orchestram/settings.gradle, content=VirtualFileContent{size=16}}(4940c49e)
4/4
Error while applying changes
This is my build.gradle before trying to import those modules (it does not change)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.qbitera.cerqana.orchestram"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '27.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
And the settings.gradle
include ':app'
Of course if I try to just include the implementation project(':callRemoteService') line in the Gradle it fails. But if try to import againg the modules from the Project Structure, it says that it is already on the project
Add to settings.gradle at the root folder:
include ':app'
include ':your_module'
include ':your_second_module'
include ':you_got_the_point'

Problems with importing libraries from github in android studio projects

I am encountering problems when trying to import libraries from github in android studio projects. Very few libraries are getting imported successfully. Here is my method of importing in android studio project:
Download zip from github.
Extract the respective library.
Import module in android studio project then import the library and adding dependencies.
Here is the error tht I am encountering when I am trying to import material drawer library whose link is:https://github.com/mikepenz/MaterialDrawer
Error:No such property: GROUP for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer
Is my method of importing libraries from github correct?
This is my module gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.works.vipul.materialdrawer"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile('com.mikepenz:materialdrawer:3.1.2#aar') {
transitive = true
}
}
You should resolve materialdrawer dependency by gradle.
Add these in your build.gradle under repositories
repositories {
mavenCentral() //add this line
}
also add this under your dependencies
compile('com.mikepenz:materialdrawer:3.1.2#aar') {
transitive = true
}

Add Two library in android studio

My application was working fine in Android Studio but when i added Library of google map.Showing an error.
package com.iremember.kiet;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.GoogleMap; //no error
import info.androidhive.slidingmenu.R;// Cannot Resolve symbol R (when added library of google map)
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 18
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "info.androidhive.slidingmenu"
minSdkVersion 11
targetSdkVersion 17
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
}
the error " Cannot Resolve symbol R" comming after i added google lib
Step 1(optional but helpful):
This is Java and not C or C++, stop trying to memorize the imports.
You are using Android Studio which is based off Intellij, turn on Optimize Imports: https://www.jetbrains.com/idea/help/optimizing-imports.html
Step 2:
Sync and Clean your project.
Step 3:
Without a doubt, you need to target the latest libs, get these from your SDK Manager:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22 // <-- was 18
buildToolsVersion "22.0.0" // <-- was 21.1.2
defaultConfig {
applicationId "info.androidhive.slidingmenu"
minSdkVersion 11
targetSdkVersion 22 // <-- was 17
}
buildTypes {
// <-- debug is debuggable by default
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.0.0' // <-- was 18
compile 'com.android.support:appcompat-v7:22.0.0' // <-- was 21.0.3
compile 'com.google.android.gms:play-services:6.5.87'
}
I have a same problem and fix it with
"sync project with Gradle files"

Using the android studio project as library in the main activity

I am trying to use shinobicharts as a library for my project app. . I am getting error when I import the library classes.Please help me to sort this out.
the project goes as
app
manifest
....
....
shinobicharts-android-library
manifest
I am using following import statements to import charts and other classes from my library.
import com.shinobicontrols.charts.Chart;
import com.shinobicontrols.charts.Dock;
import com.shinobicontrols.charts.axis.XAxis;
import com.shinobicontrols.charts.axis.YAxis;
import com.shinobicontrols.charts.data.XYDataSeries;
import com.shinobicontrols.charts.data.item.XYDataSeriesItem;
import com.shinobicontrols.charts.data.item.implementation.XYDataSeriesItemImpl;
import com.shinobicontrols.charts.series.Line;
but it colors chart, dock,axis all in red and doesnot recognise them.Please help.
here is my app.gradle yes I have mentioned it.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.rohit2906.myhistogram"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project('libraries:shinobicharts-android-library')
}

Adding 3rd Party Code to my Android Studio Project

I'm having issues when I try to use Bindroid in my Android Studio Project. I've set up a boilerplate app to create a HelloWorld example using Bindroid. I cloned the Bindroid source into my /libs folder. But when I go to run my app, I get a package Bindroid does not exist error.
I need to know how to import this code and use it with my project. For example, where should I place this code? How do I configure my project to use it? Here's my project structure:
EDIT
So I've added Bindroid according to the instructions, here is the resulting structure:
And here is my apps build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.sg.spencergardner.finance5"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':Bindroid:Bindroid')
}
And my project's settings.gradle:
include ':app'
include ":Bindroid"
You need to copy all the contents of this https://github.com/depoll/bindroid/tree/master/Bindroid under the folder name "Bindroid".
In your app's build.gradle, add.
compile project(':Bindroid:Bindroid')
:Bindroid:Bindroid corresponds to "Project Folder":"App/Library Folder". See https://github.com/depoll/bindroid/blob/master/BindroidSample/build.gradle#L5.
Also in your settings.gradle, you need to add ":app" and ":Bindroid".

Categories

Resources