Using the android studio project as library in the main activity - android

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')
}

Related

Android Studio gradle error: package com.google.gson.[different libraries] does not exist

I get the 110 errors when Gradle is building the app.
Error:(91, 23) error: package com.google.gson does not exist
Error:(94, 31) error: package com.google.gson.reflect does not exist
Error:(94, 31) error: package com.google.gson.... does not exist
...
It then tells me that this comes from the imports at my different activities, for example:
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
This is in my build.gradle which worked perfectly before the Studio update:
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "xxxx.xxx"
minSdkVersion 16
targetSdkVersion 23
versionCode #
versionName "#.#"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//...
compile files('C:/Users/Kaspar/StudioProjects/maakler.ee-app/libs/gson-2.7-sources.jar')
}
I also tried these versions which all gave the same result
compile fileTree(dir: 'libs', include: 'gson-2.7-sources.jar')
compile files('libs/gson-2.2.4-sources.jar')
The IDE does not give any warnings when I write the code. It only throws the error on Gradle build.
This all started after Android Studio update and I have no idea how to get this to work.

Cannot resolve FragmentActivity, FragmentTransaction, and more in Android Studio

So basically, every time I import something in Android Studio, say for example...
FragmentActivity and then try to use it, I just get the error:
Cannot Resolve Symbol "FragmentActivity"
Here is a full example...
import android.support.v4.app.FragmentActivity;
...
public class ReminderEditActivity extends FragmentActivity {
}
Also, Here is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.baconstripe.justanapp"
minSdkVersion 16
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'
}
Android Studio doesn't let me use many of the things I import. Please help!
simply try deleting "/.idea/libraries" from main folder. then sync project again.
You need to import the appcompat library into your project.
First, From SDK Manager, you install or update 'Android support library' to the latest version.
Next, from build.gradle, add to dependencies like this:
dependencies {
...
compile "com.android.support:support-v4:24.1.1"
}
Follow this link for detail:
https://developer.android.com/topic/libraries/support-library/setup.html
I think the issue is here:
compileSdkVersion 22
buildToolsVersion "21.1.2"
Try using buildToolsVersion that will match the compileSdkVersion or higher.
Note: This is just a suggestion, hope it helps.

Can not find symbol volley

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

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"

Categories

Resources