AndroidManifest.xml Issue - Java for Android App Development

I have decided to start learning the development side of Android, and have started on develepor.android.com. I've been following the tutorials to build the first app on there, using Android Studio. I got it to work fine, up until following the Starting Another Activity part. I guess I changed something in AndroidManifest.xml, and it absolutely will not compile now. I've ran the code validator numerous times, tried to compile it, googled for awhile, and it seems I have what it's asking for, but obviously not. the AndroidManifest.xml is:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="schemas.android/apk/res-auto"
package="learning.application">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MyActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter> />
</activity>
<activity
android:name=".DisplayMessageActivity"
android:label="@string/title_activity_display_message"
android:parentActivityName=".MyActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="learning.application.com.MyActivity" />
</activity>
</application>
</manifest>
This produces an error:
Code:
Merging main manifest AndroidStudioProjects/learning.app/app/src/main/AndroidManifest.xml
Merging result:ERROR
AndroidStudioProjects/learning.app/app/src/main/AndroidManifest.xml:12:9-23:20 Error:
Missing 'name' key attribute on element activity at AndroidManifest.xml:12:9-23:20
AndroidStudioProjects/learning.app/app/src/main/AndroidManifest.xml:16:13-22:29 Error:
Missing one of the key attributes 'action#name,category#name' on element intent-filter at AndroidManifest.xml:16:13-22:29
AndroidStudioProjects/learning.app/app/src/main/AndroidManifest.xml:17:17-18:65 Error:
Missing 'name' key attribute on element action at AndroidManifest.xml:17:17-18:65
AndroidStudioProjects/learning.app/app/src/main/AndroidManifest.xml:20:17-21:71 Error:
Missing 'name' key attribute on element category at AndroidManifest.xml:20:17-21:71
AndroidStudioProjects/learning.app/app/src/main/AndroidManifest.xml:26:9-34:20 Error:
Missing 'name' key attribute on element activity at AndroidManifest.xml:26:9-34:20
AndroidStudioProjects/learning.app/app/src/main/AndroidManifest.xml:31:13-33:71 Error:
Missing 'name' key attribute on element meta-data at AndroidManifest.xml:31:13-33:71
AndroidStudioProjects/learning.app/app/src/main/AndroidManifest.xml Error:
Validation failed, exiting
I've tried putting the package name in the android:name="foo" for the activity, and can't seem to figure out what I'm missing, I've googled around, and can't figure this thing out....apparently I'm that talented to screw up right off the bat, or not googling/understanding this? Can anyone show me what I'm missing?
**EDIT** Apparently it thinks that in the code is posting outside links, modified the top of AndroidManifest code so it'd let me post,

Figured it out, apparently, I changed the xmlns:android link to /apk/res-auto or something like that, when it should've been /apk/res/android...I removed the /res part for some reason...fixed that issue, now onto a java error.

Related

<selector> button states

I am trying to figure out how to use the <selector> resource to change custom button images depending on the state of the button. I have created button_up.9.png, button_down.9.png, button_disabled.9.png and put them in the drawable folder.
I then created this button.xml file in the drawable folder:
Code:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
 <item
android:state_enabled="false"
android:drawable="@drawable/button_disabled" />
<item
android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/button_down" />
<item
android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/button_up" />
<item
android:state_enabled="true"
android:drawable="@drawable/button_up" />
</selector>
Eclipse does not like this xml file and spits out:
Code:
error: Found tag selector where item is expected
This seems to be how all the examples I have found define their selector xml file, what am I doing wrong?
Edit:
Eclipse is no longer giving me the error above but is giving me this error on the closing </selector>:
Code:
Multiple annotations found at this line:
- error: Error parsing XML: not well-formed (invalid
token)
- Content is not allowed in trailing section.
Ok, this is really strange. I just took the xml code I had pasted above and copied it over the same code in button.xml. This time it didn't give me any errors and I can now use the selector in my layout without a problem. Does anyone know why Eclipse would have been showing these incorrect xml errors?

[Q] MapView-No Map Display

I am new to SW development with Android.
Trying to have a MapView object in my display. Code is straightforward below. But for some reason when i launch the application i do not see any map but rather the grey grid.
I have looked at many posts on the internet and i understand that it is either an INTERNET permission (which is included in my coe) or a wrong apiKey. I have gone through the apiKey several time.
Am not sure what can be wrong. Any help would be great. Thanks, Lebnen.
-----------------------------------------------
Manifest.xml
-----------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.testmap"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />
<activity android:name=".TestMapActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
-----------------------------------------------
main.xml
-----------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
androidrientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
>
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:enabled="true"
android:apiKey="0SA_n7tIj-klgGxARuFJgEos8FBGtEshpgmfogA"
/>
</LinearLayout>
-----------------------------------------------
testMapActivity.java
-----------------------------------------------
package com.test.testmap;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.LinearLayout;
import com.google.android.maps.MapView;
import com.google.android.maps.MapController;
import com.google.android.maps.MapActivity;
import com.google.android.maps.GeoPoint;
public class TestMapActivity extends MapActivity {
private MapView mapView;
LinearLayout linearLayout;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
mapView = (MapView) this.findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.setSatellite(true);
}
@Override
public boolean isRouteDisplayed() { return false; }
}
Dont see your manifest. Is it a dev map key ? Is the application debuggable in the manifest ?
Sent from my Nexus One using XDA App
1. What do you mean by dev map key? Am using the debug.keystory MD5 hash that I feed into the google page http://code.google.com/android/add-ons/google-apis/maps-api-signup.html to get the apiKey.
2. The application is debbugable in the manifest.
Ok i see your files on computer now (not on android application on my nexus one)
replace com.google.android.maps.MapView by com.test.testmap.testMapActivity
If I replace it in main.xml the application crashes; in the manifest it does not compile
Help!
the:
<uses-permission android:name="android.permission.INTERNET" />
you have to put on <manifest>, not on <application>
like
<manifest ...>
<application ...>
<uses-library android:name="com.google.android.maps" />
.
.
.
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Other thing that I'm not totally right if it's correct:
I don't know if this is correct, but for me, only worked when I create a new Android Project with Target on Google API's. Didn't work with Android 2.2 + map.jar.
Did you create with Android X.X or Google API ?
I have tried to put the INTERNET permission inside and outside the application. It does not make a difference.
I am building a Google API application.
It worked.
Weird. I had to add
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
in <manifest> outside of <application> and did it through the "Permissions" tab in Eclipse.
Thanks.
Interesting, because I thought that the "ACCESS_FINE_LOCAT ION" is used only when you try to use something with location, such as get location, distance between locations, etc..., I thought that it's not necessary when you only want to show the map
Good to know, thank you

Adding superuser to my aosp build

I'm trying to add koush's superuser to my aosp build, the build is finally going fine after following the directions on his github readme. I added the local_manifests, which gave errors at first saying no remote fetch defined. I went ahead and defined my remote in the local_manifest.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote fetch="git://github.com" name="github" />
<project name="koush/Superuser" path="external/koush/Superuser" remote="github" revision="master" />
<project name="koush/Widgets" path="external/koush/Widgets" remote="github" revision="master" />
</manifest>
I edited the device/lge/mako/device.mk to redefine the
Code:
SUPERUSER_PACKAGE := com.mypackagename.superuser
as described in the readme as well, the build comes out without errors and I seem to have no built superuser anywhere inside the zip or in the rom after it boots.
Am I just missing something simple that I'm not aware of? any advice or ideas? I'm aware that I could just drop a precompiled apk and binary into the otapackage that I build, I'd rather learn to do it this way though..
Thanks!
VoiD_Dweller said:
I'm trying to add koush's superuser to my aosp build, the build is finally going fine after following the directions on his github readme. I added the local_manifests, which gave errors at first saying no remote fetch defined. I went ahead and defined my remote in the local_manifest.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote fetch="git://github.com" name="github" />
<project name="koush/Superuser" path="external/koush/Superuser" remote="github" revision="master" />
<project name="koush/Widgets" path="external/koush/Widgets" remote="github" revision="master" />
</manifest>
I edited the vendor/lge/mako/boardconfigvendor.mk to redefine the
Code:
SUPERUSER_PACKAGE := com.mypackagename.superuser
as described in the readme as well, the build comes out without errors and I seem to have no built superuser anywhere in the room after it boots.
Am I just missing something simple that I'm not aware of? any advice or ideas? I'm aware that I could just drop a precompiled apk and binary into the otapackage that I build, I'd rather learn to do it this way though..
Thanks!
Click to expand...
Click to collapse
Why don`t you PM a rom dev. Most users cannot help you i guess. Just an idea
gee2012 said:
Why don`t you PM a rom dev. Most users cannot help you i guess. Just an idea
Click to expand...
Click to collapse
Public forum, someone else might find it useful also, if it gets figured out..
err nvm question still stands....

How make application with maps? (apiKey)

Hi, I am new in xda-developers forum. I have written my first simple application which uses GPS. Now I want to use Google Maps. Is problem because it want apiKey. My apiKey is in Google Code Api's Console. There is Android apps:
8A5:....:72:88:AE;com.borneq.heregpslocation and ApiKey : AIzaSyCh0XWRIXaTizxYcnWO8K7eFLZEysfGJvM (it is public or private?)
I modified three file to do with maps:
* AndroidManifest.xml:
Code:
<permission
android:name="com.borneq.heregpslocation.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.borneq.heregpslocation.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Code:
<uses-library android:name="com.google.android.maps" />
Code:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCh0XWRIXaTizxYcnWO8K7eFLZEysfGJvM" />
Second file is activity_main.xml :
Code:
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="AIzaSyCh0XWRIXaTizxYcnWO8K7eFLZEysfGJvM"
android:clickable="true" />
Third is .MainActivity.java :
import com.google.android.maps.MapActivity;
public class MainActivity extends MapActivity implements OnClickListener {
Click to expand...
Click to collapse
Previously used controls I commnted
Project compiles but application breaks at start. I attach source: zipped program and logCat
Thanks!
The app crashs in line 77 of MainActivity. It's a NullPointerException.
Code:
boolean isGps = locationManager.isProviderEnabled("gps");
The reason for the crash is that in onCreate you commented this line out:
Code:
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Due to this the variable locationManager is null and it crashes later because it cannot handle a null value. Just uncomment the line from onCreate which I pasted above. That's it.
How did I know that? It's in the logcat:
Code:
Caused by: java.lang.[B]NullPointerException[/B]
at com.borneq.heregpslocation.MainActivity.setButtonState([B]MainActivity.java:77[/B])
This guide might help you understand logcats (focus on that part of the guide): [GUIDE] Debugging apps You'll definitely need that knowledge if you want to do serious Android development. The earlier you learn it the better. Good luck.
nikwen said:
The app crashs in line 77 of MainActivity. It's a NullPointerException.
Code:
boolean isGps = locationManager.isProviderEnabled("gps");
The reason for the crash is that in onCreate you commented this line out:
Code:
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Click to expand...
Click to collapse
Thanks, I remove by comment old controls and not noticed that comment also locationManager (!)
I correct; removed reference to commented controls and I don't have error but I can't see maps
Is "class MainActivity extends MapActivity" but np map, only lattice

App indexing: how to?

I'm implementing app indexing and I think I'm missing something, but I don't know what.
Following the guide I added my intent-filters to the app and implemented what's needed in my activity.
my application's package is com.towers.mypackage and the associated website (where I didn't put the link rel meta-tag yet, since I'm just testing) is www.mypackage.com
I saw the following intent-filter example in the guide
HTML:
<activity
android:name="com.example.android.PetstoreActivity"
android:label="@string/title_petstore">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="www.examplepetstore.com" />
</intent-filter>
</activity>
so I wrote mine in this way:
HTML:
<activity
android:name=".ActivityForAppIndexing"
android:label="@string/title_activity"
android:screenOrientation="portrait" >
<intent-filter android:label="@string/app_name">
<data android:scheme="android-app"
android:host="com.package.myappname" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.mywebsite.com" />
<data android:scheme="https"
android:host="www.mywebsite.com" />
</intent-filter>
</activity>
Also, I wrote a content provider in order to parse the URI
HTML:
<provider
android:name=".contentproviders.HotelDetailsContentProvider"
android:authorities="com.towers.mypackage" >
</provider>
which should map the URIs as follows:
Code:
private static final String BASE_PATH = "https";
private static final String AUTHORITY = "com.towers.mypackage";
public static final Uri CONTENT_URI = Uri.parse("android-app://" + AUTHORITY
+ "/" + BASE_PATH);
I'm testing the implementation via command line using the following adb command:
Code:
adb shell am start -a android.intent.action.VIEW -d "https://mypackage.com?hotel_id=135738" com.towers.mypackage
and IT WORKS. The app gets automatically opened with the right activity and the right parameters. When the app starts the onNewIntent method gets called:
Code:
protected void onNewIntent(Intent intent) {
String action = intent.getAction();
String data = intent.getDataString();
if (Intent.ACTION_VIEW.equals(action) && data != null) {
String recipeId = data.substring(data.lastIndexOf("/") + 1);
Uri contentUri = HotelDetailsContentProvider.CONTENT_URI.buildUpon()
.appendPath(recipeId).build();
bundle = new Bundle();
bundle.putString("pictureUrl", "");
//showRecipe(contentUri);
}
}
(I got it of course from the examples, that's why it talks about recipes)
But I wonder: what should I do? Get data from the intent with a
Code:
getIntent().getData().getQuery()
or use the ContentProvider and get them from the URI?
Also, I'd like to test with the Google Search Console and the "View as google" funcionality if everything is okay. I uploaded my APK and saw an URI is requested.
Now, in the "testing your app" section of the documentation I saw that the links like http://mypackage.com?hotel_id=135738 are referred as "deep links" while those like android-app://com.towers.mypackage/https/mypackage.com?hotel_id=135738 are referred as "URI". Am I right?
The "View as google" funcionality asks for a URI but I don't know how to create one. Also, I wonder how this URI is passed to the app and I'm pretty sure I'm getting very confused about this all URI/deepLink thing, and can't find relief in the documentation.
Where and when should I use the URI? Where and when should I use the deepLink? I guess that since I'm going to put the link rel=URI in my webpages then the app will be called in the app indexing with the URI and not with the URL of the page. But if it's so... why is the adb shell am start -a android.intent.action.VIEW -d command used for testing with the URL and not the URI? Should my app be able to get and handle URIs or URLs? And how?
I thought I had understood something about app indexing, but today I'm starting to think I got it all wrong since I started. That's why I ask you for help in answering the questions above, and possibly sheding a light on all this URL/URI/intent-filter/ContentProvider mess.
I already talked about this on Stackoverflow and got two answers, plus a lot of comments. But I wasn't able to get anything from that, App indexing remains a mysterious monster to me :-/
Did anyone of you manage to make this kind of things work? And how?
Thank you everybody, really.

Categories

Resources