So I am trying to work through the example here:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/SurfaceViewOverlay.html
and on the last import line it says
//Need the following import to get access to the app resources, since this
//class is in a sub-package.
import com.example.android.apis.R;
Question is where do I get the package that contains this? I found very little info online and obviously don't have it already since it's underlined red when I type it. I know this is probly a noob question but hey we all start somewhere...
Try to run this example using the android sample app.
To install and run the Android Sample apps follow the instructions here:
http://developer.android.com/resources/samples/get.html
To help you get started quickly, the Android SDK includes a variety of
sample code and tutorials that illustrate key concepts and techniques
of Android application development. For example, the samples show the
structure of the manifest file and the use of activities, services,
resources, intents, content providers, and permissions. They also show
how to add specialized capabilities to your apps, such as Bluetooth
and Contacts integration, multiple screens support, Live Wallpaper,
and more.
That R file is simply the R file of your project. So it will be your.project.main.package.R depending on the package attribute of the <mainfest> tag in your AndroidManifest.xml.
So if you have imported the project sample from the SDK, the R file would be in the same package as the example, i.e. com.example.android.apis.
However, if you are using the code in your own project as I assume is the case because you have mentioned the import remains unresolved, then you have to import the R file for your own project. Note that you will also have to import the required resources (layouts, drawables, etc) into your project from the sample.
In my case, I was getting this error because I needed to add the:
C:\adt-bundle-windows-x86_64-20130729\sdk\add-ons\addon-google_apis-google-18\libs\maps.jar
to the Libraries tab in the BuildPath section of "right-click over project" / Properties.
Related
I have a simple calculator app. It's a complete application all by itself.
I also have a more advanced calculator app that's based on the first app, but has more features. Its main Activity extends the first app's main Activity. The advanced app references quite a lot of resources and methods from the simpler app.
Getting the advanced app to build under Android Studio has been a nightmare. I've been googling and trying things blindly in the build.gradle files, but not making much progress. At first, the problem was dependent features configured but no package id was set (whatever that means, Google turned up no documentation.)
I got past that by tweaking the build.gradle files, and now I'm getting Manifest merger failed with multiple errors, see logs, but I can't find the relevant logs. It looks like the build failed because Android Studio tried to merge the AndroidManifest.xml files from the simple app and the advanced app, but I just wanted to use the manifest from the advanced app.
This is all very frustrating because I made it all work under Eclipse but now I have to move to Android Studio.
I guess my first question is: How can I tell Android Studio to just use the Android Manifest from the current project and not try to merge from the other project.
In general: can an application project serve as a library for another project, and if so how? Are there any examples?
Third question: where can I find good documentation on build.gradle?
I could attach my current build.gradle files and AndroidManifest.xml files if people need to see them, but I'm really hoping to learn enough that I can help myself.
Confirm the problem first:
Switch the same model in Library / application
Application ID androidmanifest conflict problem
if this is the problem, the official documents can see the channel packaging
https://developer.android.google.cn/studio/build
And I wrote you a little demo
https://github.com/yuanweiwork/lytools
I hope it can help you
I have strange problem with generating process. After click on Generate Cloud Endpoint Client Library everything works right, but if I look in the endpoint-libs/ folder I saw that former folder structure was changed.
First part of it is still ok endpoint-libs/libmyname-v1/myname/myname-v1-generated-source/
but next one is com/google/api/services/my.package.name/myname/ and com/google/api/services/my.package.name/myname/model/.
Despite it every single .java file of generated libraries has in my opinion wrong package:
package com.google.api.services.my.package.name.myname.model;
If anyone encountered this problem and solved it?
This is a known issue. You can see the workaround here, or follow this bug entry for status of a fix.
Google just posted GPE 3.2.3 and a server side fix which appears to correct the issue; however, existing code is not necessarily backward compatible. As an example, changes are required in the standard Google generated GCMIntentService:
Migrated to usage of the new com.google.api.services path, as:
import com.google.api.services.deviceinfoendpoint.Deviceinfoendpoint;
import com.google.api.services.deviceinfoendpoint.Deviceinfoendpoint.Builder;
import com.google.api.services.deviceinfoendpoint.model.DeviceInfo;
Modified the call to insert methods from:
endpoint.insertDeviceInfo(new com.google.api.services.deviceinfoendpoint.model.DeviceInfo().setDeviceRegistrationID(registration)).execute();
to:
endpoint.deviceInfoEndpoint().insertDeviceInfo(new com.google.api.services.deviceinfoendpoint.model.DeviceInfo().setDeviceRegistrationID(registration)).execute();
I have been unable to find the official documentation on why this breakage was required and rationale.
So I'm pretty new to Android Development and I'm curious if I'm missing anything when I'm importing libraries into my android project. I followed this guide on android website and made a new project out of existing code then added it as a library into my own project. The problem is everything errors out, R cannot be resolved as a variable so I tried to clean my project and it does nothing. I import R then it can't find any of my activities. So there's my first problem.
The library I'm using is This Color Picker and really on the homepage it just says to use the xml and add it to my preferences but my preferences doesn't seem to recognize it.
I'm obviously doing something wrong but can't seem to find a decent tutorial to walk me through adding custom libraries to my project. I was hoping someone with more experience could help me find the root of my errors or point me to a tutorial so I can start the import process from scratch.
Am image of my settings file
The library I'm using is This Color Picker
Any library that doesn't publish a complete sample app that uses the library should be ignored, IMHO.
I'm obviously doing something wrong
Presumably, there is no color resource named pumpkin_orange in your project. There definitely is no such resource in the library. Either define this color resource, or replace #color/pumpkin_orange with a literal color or some color resource that you define.
Your R class does not exist because you have bugs in your resources (like the settings.xml one) and/or your manifest. Once those bugs are cleared up, your R class should generate properly.
I am having some problem. When I run an console application in eclipse (non-android) I imported google-api-client-googleapis-1.4-beta.jar google-http-client-1.8.3-beta.jar
It work!!
but when I import the same thing into my android application, it fail at new com.google.api.client.http.apache.ApacheHttpTransport(); [ClassNotDef Exception]
Then I follow a lot of the post suggesting a list of library, download all of them, and import all of them.... but it still doesn't should The way I import is right click on the project->config build path -> library -> add external jar file..
So once it switch to android application, it can't find the class. I thought I import the class properly, but since I am having the classNotDef I don't think I am. Anyone knows the reason why????
Any Hints will be good.
Or maybe suggest a list of libraries require for project.
Thanks a ton.
Lawrence
The class you are looking for does not exist in Android's package structure. There are two solutions to this problem:
1: You can check out the corresponding package's documentation and use a different class.
2: On the other hand you can take the class you want and package it with your application. Then it is guaranteed that it will be found.
I am new to the concept of ZXing,so i want to know the step by step process to use the ZXing in android and i am using elicpse as IDE.Any one knows about it please help me.
As advised by the moderator, I am posting what did to import zxing into my android app, on this post. Seems like many people refer to this post to get an answer for zxing.
The zxing guys have made it easier to create a android project with 1.7. Its not as painful as it used to be. This is a quick blog for anyone who would like to create a zxing project for android quickly.
Checkout the zxing sources from zxing.org
Create a Android project on your eclipse
Delete main.xml
Right click on “src” directory and hit import. Browse to the following directories in the order mentioned. As you add them for
import one by one, ensure that you have the src directory in the edit
field of the import wizard. And that you select only the “com”
directory on the left directory tree. Do not select src.
core
android-integration
android
Ensure that your android sdk version is 9, anything lesser and androidmanifest.xml will cry.
Strings.xml in one of the languages will crib, just put a / before the ‘ character
For the benefit of people,
I have a android hello world integrated with zxing 1.7 http://www.4shared.com/file/bFx8Y5Ys/zXingJune2010.html
Another blog that has interesting direction for integrating zxing
http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/