android.support.v13.dreams.BasicDream cannot be resolved - android

I'm trying to work on extending BasicDream which exists in package: android.support.v13.dreams. I have tried downloading all most all android version (just trying luck to get it working) but I'm unable to import it. i.e. On
import android.support.v13.dreams.BasicDream; statement I'm getting an error:
The import xxxxxx... cannot be resolved.
I tried copying my sdk/extras/libs/../android-support-v13.jar in my libs folder and added to build path but found this package does not show dreams. While typing import statement I'm able to see v13 i.e. I can write import android.support.v13.app.*; but it does not have dreams/basicdream.
Tried google and do found the source code of this class but no idea why my jar file does not have these classes or how to use it. Please suggest what am I missing here.
Update: Finally I figured out that BasicDream was part of Android Support Library version 13 Link: BasicDream source codeshipped with android 4.1.2 however latest Android Support Library version 13 does not have Basic Dream.support library v13 class list
As I'm working on some native functionality, I downloaded BasicDream source code from the link mentioned above and included in same folder where I have my other source files. Updated the package to my application package

In your case probably the best way to get it is to check code of this class on GrepCode and manually resolve (copy) all dependencies. Good luck!

Related

cannot find symbol class DiskInfo and some other packages despite being present in SDK folder

I have an activity in which i have imported android.os.storage.DiskInfo and some other packages. Android Studio gives errors when trying to make the project saying:
error: cannot find symbol class DiskInfo
When i tried to resolve this problem i found out that all packages are present in folder $SDK-HOME\sources\android-24\android\os\storage but i don't know why Studio couldn't import them properly.
Is there anybody who have experienced problems in import and have solved it?
Thanks
p.s: i am using Android API 24
That is because of #hide in android source code. Actually Android is not allowing developers to use some classes. A solution is to use modified SDK which contains hidden classes. you can find it here https://github.com/anggrayudi/android-hidden-api
Check out : TargetSdk version and support package version.

Android Studio cannot resolve symbol utils when trying to migrate CSipSimple

I'm using CSipSimple. I followed the migration guide from Eclipse to Android Studio carefully and the only error that I am getting is
cannot resolve symbol utils
and is happening on below lines:
import com.actionbarsherlock.internal.utils.UtilityWrapper;
import com.csipsimple.R;
In build.gradle, I have added the following line:
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:19.0.+'
}
Does anyone know why this would be happening? Any suggestion will be of great help.
ActionBarSherlock-4.4 does not have the package utils.
Check the version that was used before migrating to Android Studio.
VenomVendor's answer already provides the reason: there's no UtilityWrapper on ActionBarSherlock. So, I'll try to provide the fix instead.
tqcenglish has a GitHub repo for Android Studio port for CSipSimple. Its readme says:
Change
/res/values/wizard_sipgate_string.xml
<string xm:lns:ns0="http://schemas.android.com/tools" /> -
<resources xmlns:ns0="http://schemas.android.com/tools"/> +
delete jni folder
add jniLibs folder and org.pjsip.pjsua to java folder
delete about quote UtilityWrapper
Reference
com.actionbarsherlock:actionbarsherlock:4.4.0#aar
This seems to give a hint of removing any reference to UtilityWrapper, including import com.actionbarsherlock.internal.utils.UtilityWrapper;. However, it might compromise something.
You're on the right path to use com.actionbarsherlock:actionbarsherlock:4.4.0#aar for the dependency.
Alternatively, I don't see any reasons why files under utils won't work outside of com.actionbarsherlock.internal package, so you should be able to copy all files from com.actionbarsherlock.internal.utils to your java folder, then replace the import statement to use the corresponding package.
If you get this error while trying to use OpenCV, import this:
import org.opencv.android.Utils;

The import android.support.test can not be resolved in revision 22

I am trying to use the support library for testing in Android. However, when I try to import
import android.support.test.runner.AndroidJUnit4;
as it is described here it says
The import android.support.test can not be resolved
I want to use revision 22 as I want to use the new features presented for UiAutomator.
There is no support\test folder in sources
I was digging around the sdk folder and I've notice that even though the path sources\android-21\android\support\test exists, sources\android-22\android\support has no test folder (there is a tests one but only with GrantActivity.java inside).
Did I forget to import any jars? (I tried importing support-annotations, and support-v4 but it's the same result).
Am I doing something wrong? I hope so and that you guys can help me figure it out.
Thanks in advance!
Note: I have downloaded the Android Support Repository and Library, I have all the packages from API 22 and I have Tools, Platform-Tools and Build-Tools up to date.
(I don't think it matters but I'm using Eclipse Kepler in Windows 7)
This isn't really supported, but since you're using Eclipse, you'll need to import the jar manually. The Android Support Repository gets downloaded to <SDK_DIR>/extras/android/m2repository. The class you want is part of the testing-support-lib, which is in the repository under com/android/support/test/testing-support-lib/0.1
Android uses .aar files for libraries, and the testing-support-lib is published as an aar. This format isn't supported by Ant, but if you unzip the testing-support-lib-0.1.aar file, it contains a classes.jar file that you can import.
As mentioned in the comments, you really should make the switch to Android Studio and use Gradle going forward so that you don't have to jump through these hoops.

Cannot import google cloud endpoints client library class in Android project

I'm having difficulty getting Google Cloud Endpoints working. I have an Python endpoints project running on GAE and it works perfectly using the api explorer. However I'm struggling to properly generate the client library and use it in my android app. I've tried a number of sample projects and have the same problem every time; I can't import and use the model classes from the client libraries.
Here's what I'm doing (for this example I'll use the helloworld api python sample at https://github.com/GoogleCloudPlatform/appengine-endpoints-helloendpoints-python)
Unzip the sample code
Generate the client library by navigating to folder and running
<gae-sdk>\endpointscfg.py get_client_lib java helloworld_api.HelloWorldApi
Unzip the generated folder and copy into root of project in eclipse
In Eclipse add "your_app_id_appspot_com-helloworld-v1-20140310110152-java-1.17.0-rc-sources.jar" to build path (Right click the JAR> Build Path>Add to Build Path)
At this stage, I can import com.appspot.your_app_id.helloworld.model.*but I cannot import com.appspot.your_app_id.helloworld.model.Greeting
Can anyone shed any light on what's happening here? I have tried many different ways to get this to work but have the same problem every time.
Many thanks,
Tom
The problem is that by default, the generated zip file only contains a sources jar, not an actual compiled library jar which your Android app can use.
Here's the solution:
In your backend api folder (from the same place where your app.yaml is located), generate the client library as a gradle library, like so:
<gae-sdk-path>\endpointscfg.py get_client_lib java -bs gradle helloworld_api.HelloWorldApi
You'll now have a helloworld-v1.zip. Unzip this (either right here or in somewhere convenient like ~/temp)
This will create a folder called helloworld, which should have a build.gradle in there along with a src folder.
Build your client library using "gradle install" in this folder.
Copy build/libs/helloworld-v1-1.X.X-SNAPSHOT.jar into your Android app's libs folder.
Add it as a library in Android Studio by right-click/add-as-library.
Your classes should now resolve correctly.
Step 4 should install the just-built client library into your local maven repository. You can follow the instructions in readme.html in the helloworld/ folder you extracted to integrate directly with your Android app's gradle build system instead of copying the jar your built manually.
This post said that there is a bug with Android Studio's Add As Library: Android Studio: IncorrectOperationException when 'Add as Library' is clicked whilst trying to configure Google Apps Endpoints client libraries
Not sure if it applies to Eclipse.
I was able to solve this problem and have provided the solution below.
I switched to Android Studio Preview 0.4.6 from Eclipse which helped get rid of some of Googles library import issues(through I guess build.gradle config). I feel it was not a problem of Eclipse which I was using earlier.
I was able to to fix the import issues. The code on the tutorial segments on the official Google docs needs to be put in sync.
The solution is to roughly do the following changes:
In MainActivity.java, replace:
HelloGreeting with HelloworldApiGreeting
In MainActivity.java, add the following at the top:
import android.widget.Toast;
import android.os.AsyncTask;
import android.util.Log
import com.appspot.androidbackend1.helloworld.model.HelloworldApiGreeting;
import com.appspot.androidbackend1.helloworld.model.HelloworldApiGreetingCollection;
In MainActivity.java, comment the following at the top:
import com.appspot.androidbackend1.helloworld.Helloworld.Greetings.Multiply;
import com.appspot.androidbackend1.helloworld.model.HelloGreeting;
In Application.java, add the following at the top:
import com.appspot.androidbackend1.helloworld.model.HelloworldApiGreeting;
In Application.java, replace:
HelloGreeting with HelloworldApiGreeting
Hope this saves time for others

Android - NoClassDefFoundError after jar changed

I know that there are some similar questions, but no solution helped me.
I am getting a java.lang.NoClassDefFoundError when I try to access an (existing) class
in a self-created .jar from my projectgroup.
This .jar works fine in an normal javaProject but doesn´t work with Android.
But an older version of this .jar worked fine with Android.
I am developing with Eclipse + Android Development Tool - Plugin (Version 21)
I have put the .jar in the Project_Home/libs folder.
There are no errors at compiletime.
Before the exception was thrown, there was some "dalvikvm - could not find class ... referenced from ..." errors.
I think, there could be a problem with the Java Version, because our projectgroup recently started to use Java 7, but I am not sure and have no idea how to fix it.
Thanks a lot for your help.
Rename your lib to libs and update the build path and then try again
I think if the project is compiling fine then we can rule out any error in copying or java buildpath. The only other time i get this error is when my import is wrong in the code. I would suggest you to re-check your import and recreate R.java file.
Make sure that your classes do not have same names as ones already present within Android. Upon building the package, due to "optimization" classes with same names are omitted.
Android libraries are mostly compiled against 1.5. Not all libraries are also present within Android. Your package may depend on some other library that is not present within the system.
Ordinarily I don't want to answer my own question but I hope it will help someone.
I didn't see an other warning (not in Logcat, it was in the console):
"Dx bad class file magic (cafebabe) or version (0033.0000)"
I had found this Warning in an other Stackoverflow question.
I had opened one of the class file from the not working .jar with an HexEditor
and changed the Major-Version-Byte to 0x32 and it worked.
I know this is not a solution, because there could be features from Java 7 in the class,
so the class file no longer work, but it proves that it was a problem with the Java version

Categories

Resources