In android studios, I have successfully imported a library called ChatKit(https://github.com/stfalcon-studio/ChatKit). The creators of the library were kind enough to include a fully working sample within the library. Instead of recreating the process I want to import the sample from the library into my project but android studios is not allowing me to do so.
In my main activity, I can add :
import com.stfalcon.chatkit.dialogs.DialogsList;
But when cannot add:
import com.stfalcon.chatkit.sample.ChatSamplesListAdapter;
So I'm curious what other people have done to import a sample from an already imported library.
Thank you.
import com.stfalcon.chatkit.sample.ChatSamplesListAdapter;
It happens because this class is not included in the library.
It is a sample file used as sample.
As you can see it is just a simple RecyclerView.Adapter then you can copy it in your project or you can use a own adapter.
Related
I am trying to implement the Google Play API into my Application.
Google says to import BaseGameUtils as library and add this library to my project:
this "main" is the BaseGameUtils, I have no idea why it's called "main".
However, here You can see that it's the BaseGameUtils project:
As You may see, there are the three classes, BaseGameActivity, GameHelper and BaseHelperUtils.
No when I try to import the BaseGameActivity I get following:
But strangely, I can import
com.google.example.games.basegameutils.*;
But when importing this, I still can't use the BaseGameActivity.class
What am I doing wrong?
One thing that you have done wrong is that you are trying to import BaseGameActivity into your application project.
I am assuming that you have already done this:
https://developer.android.com/google/play-services/setup.html
Then follow this:
https://developers.google.com/games/services/android/quickstart
In essence, you import the TypeANumber and BaseGameUtils code from the Android samples into your workspace (not into your application project).
Then you confirm that both Google Play services and BaseGameUtils are defined as library projects (Properties .. Android .. Is Library should be checked).
Then IN YOUR APP PROJECT add them as references (Properties .. Android .. Reference ..Add)
But I have just emphasised key steps that I suspect you may have misunderstood or omitted. You have to follow the whole thing carefully. Good luck !
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
I want to use this library to crop images, since the crop intent can cause problems on certain devices: https://github.com/lvillani/android-cropimage
If I import it in Eclipse however, I get some errors in Eclipse.
In the Util class I get an error on this
options.inNativeAlloc = true;
inNativeAlloc cannot be resolved. Also I get another error in the CropImage class:
MenuHelper.showStorageToast(this);
The MenuHelper class isn't included in the library.
Since if seen these kind of errors on another library I want to know if there is something that I'm missing or doing wrong.
I'm saving the library as a zip file, extract the zipfile and import the library folder in Eclipse by using import > Existing Android Code into Workspace. I think this is ok since I checked the source on Github to comfirm if I'm missing something.
This isn't a new issue for the project as you can see on the issue page. To solve it you could follow the recommendations made in that post or you could download/get the develop(the same way) branch which, at a quick look, doesn't seem to have those problems.
The project that you are using already is an android library. You should just download the entire source folder and use Import existing project (the .project file is already in github).
Then in your own project create a reference to it by going into project properties -> android -> library -> add
About inNativeAlloc - it is a hidden field... To set a "true" value to it you must use this code: setInNativeAllocTrue(opts)
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!
I want to test the sample of android-sdk-windows\extras\android\compatibility\v4 in the sdk1.6 +. In the eclipse, I want to import the sample, but the app shows mistakes. I also added the jar to the sample, but it also shows mistakes. Can you tell me how to import the sample to the eclipe?
If importing the sample fails,Try creating new project from existing source option.
File->New->Android project => check create from existing source