should I use google drive bat I can't compile this activity
package com.google.android.gms.drive.sample.demo;
import android.app.Activity;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
/**
* An abstract activity that handles authorization and connection to the Drive
* services.
*/
public abstract class BaseDemoActivity extends Activity implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
...
I use Google Plugin for Eclipse to install the library and google APIs
but since compile error
GoogleApiClient cannot be resolved to a type
Follow the Google+ Platform Quickstart for Android in order to install Google Play Services as a library project.
In particular see step 5:
5. Import the Google Play Services library project.
Select File > Import > Android > Existing Android Code Into Workspace and click Next.
Select Browse.... Enter <android-sdk-folder>/extras/google/google_play_services/.
Select google-play-services_lib. Click Finish to import.
Related
I am new to developing on Android Studio, my app was running fine until the studio exited abruptly after that the project cannot find any of the libraries imported (in asterisks) like Uri, AppCompatActivity etc to my AppCompatActivity class (I am using Android 2.1.2)
import android.net.*Uri*;
import android.os.*Bundle*;
import android.support.v7.*;
import android.util.*Log*;
import android.view.*View*;
import android.widget.*AdapterView*;
import android.widget.*ListView*;
import com.google.android.gms.appindexing.*Action*;
import com.google.android.gms.appindexing.*AppIndex*;
import com.google.android.gms.common.api.*GoogleApiClient*;
import org.xmlpull.v1.*XmlPullParser*;
import org.xmlpull.v1.*XmlPullParserException*;
import org.xmlpull.v1.*XmlPullParserFactory*;
import java.io.*IOException*;
import java.io.*InputStream*;
import java.util.*ArrayList*;
import java.util.*List*;
public class Menu extends android.support.v7.app.*AppCompatActivity* {
What I have tried uptil now:
checked projectstructure -> app -> dependencies
tried sequencing the libs
com.android.support:appcompat-v7:24.2.1
com.google.android.gms:play-services-appindexing:8.1.0
before junit:junit:4.12
Checked build.gradle and added above 2 dependencies
Clean Project
Build APK
ReBuild Project (many times)
P.S: com.google.android... imports were auto generated with onstart and onstop overrides (no idea why)
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
P.S: My Android Studio is installed in C:/Programfiles and my project is saved in a different location under AndroidStudioProjects folder
I have been finished step 3 of "Getting Started with the Facebook SDK for Android" from facebook developers support and this is code from the Sample directory :
package com.facebook.samples.profilepicture;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class ProfilePictureSampleActivity extends FragmentActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile_picture_sample);
}
}
When I try to run ProfilePictureSample there are some errors like this :
"The import android.os.Bundle cannot be resolved"
"The type android.app.Activity cannot be resolved. It is indirectly
referenced from required .class files"
"The hierarchy of the type ProfilePictureSampleActivity is
inconsistent"
So how can I fix them ? It's strange because if I build a simple activity project with android.os.Bundle works fine.
Probably the problem is the holder api version that the application of this code request because I suppose that android.os.Bundle is for api 17 of android sdk. So it can be resolved by go to "android sdk Manager" and download the version of requested api.
I am trying to get google maps to work in my android project. I have already got the md5 key and signed up with google to get the api key, but now when i am trying to display the map, I get an error when importing it. "com.google" has the sqiqly red line under it.
Can anyone help?
Thanks
this is my xml file: (note: i replaced the key with 'my_key' since i didnt want to make it public)
<com.google.android.maps.MapView
android:id="my_map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="my_key"/>
and for the java file:
package com.escortme.basic;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import com.google.android.maps.MapActivity; // ERROR
import com.google.android.maps.MapView; // ERROR
import android.os.Bundle;
public class Police_ViewActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.pol_view);
}
public void quit_button_action(View view){
finish();
}
}
It sounds like you don't have the Google APIs referenced by your project. Assuming you're using Eclipse, view the properties of your project and select Android and check that Google APIs is checked rather than simply an Android version.
You may need to download the Google APIs if you haven't already. You can do this through the Android SDK Manager.
I am trying the google maps api for android, but eclipse does not import the com.google.android.maps.* files.
Source:
MyMapActivity:
package org.madmax.map;
import android.app.Activity;
import android.os.Bundle;
import com.google.android.maps.*;
public class MyMapActivity extends MapActivity {
private MapView map;
private MapController controller;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
in the Manifest file I have already declared:
<uses-library android:name="com.google.android.maps" />
How do I import the com.google.android.maps.* files?
It is not enough to just have the API SDK installed. From the android maps documentation,
http://code.google.com/android/add-ons/google-apis/maps-overview.html
If you want to add Maps to an existing application, right-click the project in Package Explorer, choose Properties > Android and then select a build target from the list displayed. You must choose the "Google APIs" build target.
(The standard Android packages don't include Google Maps)
Update, found a screenshot online, don't pick a Target with the name "Android x.x" pick the corresponding target that says "Google APIs" for the version of Android you want.
Make sure you have the Google APIs installed in your SDK. Open the SDK manager from the tools directory and use it to install the package.
Right now I am able to get access to the hidden and internal android APIs, but now I want access to things like AlarmManagerService which is in server. I used adb pull system/framework/services.jar changed services.jar to services.zip which unpacked a directory of all the server classes (including AlarmManagerService which I was looking for). My question now is how can I add those server classes to my android.jar file which I can then use in Eclipse?
I hope that makes sense the way I worded it. Let me know if there is any confusion I can clear up.
EDIT: Essentially, when all is said and done, I want to be able to do something like below without any errors:
import com.android.server.AlarmManagerService;
public class TestActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AlarmManagerService ams = new AlarmManagerService(this.getApplicationContext());
ams.setTime(1313);
}
}
ANOTHER EDIT:
I figured this out after looking at all the source code.
Classes like AlarmManagerService just have package visibility which is why it cannot be imported. Some classes are public, but many other com.android.server classes have package constructors so they can't be instantiated.
Here are the com.android.server.* I was able to import and successfully create an object of:
import com.android.server.AttributeCache;
import com.android.server.BootReceiver;
import com.android.server.BrickReceiver;
import com.android.server.ClipboardService;
import com.android.server.ConnectivityService;
import com.android.server.DevicePolicyManagerService;
import com.android.server.DiskStatsService;
import com.android.server.DropBoxManagerService;
import com.android.server.EntropyService;
import com.android.server.InputMethodManagerService;
import com.android.server.LocationManagerService;
import com.android.server.MasterClearReceiver;
import com.android.server.NativeDaemonConnectorException;
import com.android.server.NetStatService;
import com.android.server.NotificationPlayer;
import com.android.server.ProcessMap;
import com.android.server.ProcessStats;
import com.android.server.SystemBackupAgent;
import com.android.server.SystemServer;
import com.android.server.ThrottleService;
import com.android.server.TwilightCalculator;
import com.android.server.Watchdog;
import com.android.server.connectivity.Tethering;
import com.android.server.status.AnimatedImageView;
import com.android.server.status.CloseDragHandle;
import com.android.server.status.DateView;
import com.android.server.status.ExpandedView;
import com.android.server.status.IconMerger;
import com.android.server.status.LatestItemView;
import com.android.server.status.NotificationData;
import com.android.server.status.NotificationLinearLayout;
import com.android.server.status.StatusBarService;
import com.android.server.status.StatusBarView;
import com.android.server.status.StorageNotification;
import com.android.server.status.TickerView;
import com.android.server.status.TrackingPatternView;
import com.android.server.status.TrackingView;
import com.android.server.status.UsbStorageActivity;
android.jar contains only the public API's class files and I think you made changes in 'com.android' package or its internal packages. So to reflect the changes in eclipse you have to add the path explicitly to your service.jar to your project. But remeber this will not reflected at run time, since the emulator or the device you are using have not been updated your changes. And you can't update them by simply modifying the jar file, since the device or emulator uses the image 'system.img' which internally have .dex file as library not the .jar file for internal APIs. To make changes for device/emulator you have to build the whole code and for that you can refer the http://source.android.com/source/index.html.