android:targetPackage cannot resolve symbol - android

this might seem trivial but I can't understand why I'm getting this error.
I downloaded the sample app activityInstrumentation( from Android Studio File -> import Sample) and inside the testing project manifest I get an unresolved symbol for
android:targetPackage="com.example.android.activityinstrumentation".
After that I've created a manifest for my application and still there is an unresolved symbol on the attribute.
My application project dir and test project dir are:
app/src/main/java/com/example/appname
where manifest has
package="com.example.appname"
app/src/androidTest/java/com/example/appname
where manifest has
<manifest
...
package="com.example.appname.tests"
...
android:targetPackage="com.example.appname"
...
</manifest>
Please help me sort this out. I don't know what else I can do: using a sample app to create a full fledged test project was my very last hope.

You must specify android:targetPackage in instrumentation tag.
[http://developer.android.com/guide/topics/manifest/instrumentation-element.html
]

I see the same thing. Seems to be only false alert produced by the lint code inspection. When you run analysis (Analyze->Inspect code...) and open "Inspection" tab you can select the warning and mark it Suppress for tag. That will get rid of the warning.

Related

"MissingRegistered" Lint warnings when using com.google.android.material.* UI components

I'm trying to get rid of the Lint warnings in my Android project. Doing so I run into the following type of warning messages that I do not understand:
app\src\main\res\layout-land\event_settings_fragment.xml:25: Error: Class referenced in the layout file, com.google.android.material.textfield.TextInputLayout, was not found in the project or the libraries [MissingRegistered]
<com.google.android.material.textfield.TextInputLayout
^
My app seems to be running fine, so the com.google.android.material.textfield.TextInputLayout class should be available in the project?
Note that I do get this warning on all com.google.android.material.* classes.
MissingRegistered
Summary: Missing registered class
Priority: 8 / 10
Severity: Error
Category: Correctness
NOTE: This issue is disabled by default!
You can enable it by adding --enable MissingRegistered
If a class is referenced in the manifest or in a layout file, it must also
exist in the project (or in one of the libraries included by the project. This
check helps uncover typos in registration names, or attempts to rename or move
classes without updating the manifest file properly.
See: http://tools.android.com/tips/lint-checks
If you ensure that the layout file runs without problems, you can disable the check:
app/build.gradle
android{
lintOptions{
disable "MissingRegistered"
}
}
or add tools:ignore="MissingRegistered" in the layout file to suppress the check.

I can't build or run my project

I tried to build and run my program. but I saw this message. what can I do?
Rishe is app name
Error 1 :
Error 2 :
Thanks in advance !
android.name is the class of your activity, not the application's name. Check the android developer's startup document.
error1 -> there is conflict coming with your app module manifest file with other module manifest file. see manifest merger tool http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger or find how to merge mainifest file
error2 -> you are defining 3 activity with same name that is why it is giving error

How can I work with the settings app of aosp?

I just started working on android open source project and I am trying to modify the settings application but when I am importing it with android studio and trying to compile I get this error
Error:Execution failed for task ':app:mergeDebugResources'.
/app/src/main/res/values-nl/strings.xml: Error: Found item String/sdcard_unmount more than one time
Seems like there are multiple statements of string such as
<string name="sdcard_format" product="nosdcard" msgid="6285310523155166716">"USB-opslag wissen"</string>
<string name="sdcard_format" product="default" msgid="6713185532039187532">"SD-kaart wissen"</string>
It is causing errors, how can it be fixed?
For anyone looking for answers, this other one in SO is much better: Error:Error: Found item String/photoPickerNotFoundText more than one time
you need to change the package name, because u r installing setting app on device which already have the setting app with same package name. you have to import the code modify it and then copy the new src and res directory in to aosp and create the image of android.

"trouble writing output: Too many field references: 70185; max is 65536. You may try using --multi-dex option." when building Android project

I hit this error and found no hits for the error message, so I thought I'd share the solution I came up with to save anyone else facing the problem repeating my work.
When writing a new Android library (apklib) for use in a (large) application, I'm getting the following error during dexing when I add my new project as a dependency:
trouble writing output: Too many field references: 70185; max is 65536.
You may try using --multi-dex option.
References by package:
<...long list of packages with field counts elided...>
The particular build step it fails on is:
java -jar $ANDROID_SDK/build-tools/19.0.3/lib/dx.jar --dex \
--output=$PROJECT_HOME/target/classes.dex \
<... long list of apklib and jar dependencies elided ...>
Using --multi-dex as recommended by the error message might be a solution, but I'm not the owner of the application project and it already has a large complex build process that I would hesitate to change regardless.
I can reproduce this problem with a no-op test library project that has literally no fields, but in the error output it's listed as having 6000+ fields. Of the packages listed in the error output, there are a handful with similar 6k+ field counts, but then the vast majority have more plausible <1k field counts.
This problem is similar to the "Too many methods" problem that Facebook famously hacked their way around. The FB solution seems insane, and the only other solutions I've found (e.g., this Android bug ticket, or this one, this SO answer, this other SO answer) all involve changing the main app's code which is well beyond the scope of what I want to do.
Is there any other solution?
The solution was to change the package in the AndroidManifest to match the main application's package.
A manifest like this:
<manifest package="com.example.testlibrary" ...
resulted in 6k+ fields and build failure. Changing it to match the main application's package
<manifest package="com.example.mainapplication" ...
resulted in the project building successfully.
Note that only the package in the manifest is changing, I did not make any changes to the library's Java source or its layout (the Java package was still com.example.testlibrary with directory structure to match).
I hypothesize that the different package name is causing all the Android fields to be included again under that package. All the packages in the error listing with 6k+ fields had a different package name than the main application.
I also (later, grr), found this blog post which details the same problem and the eventual same solution.

Error NullPointerException when running an altered version of an Android Project

I have this Android program running well, called TestePHP2 (name of main class), package com.testedeacesso.www. It is stable and runs perfectly.
I've cloned this project's folder to start developing an upgrade to it. I called it TesteTempo01, after importing it to Eclipse - option 'from existing project' (yes, I used the refractor to change the class name and I checked 'update references'). I modified this program's main class as I mentioned before and added some code to it, but I kept the package name the same, as well as other classes from the program.
Whe I try to run this program, though, I got a 'can't find main activity' error. After searching through my code, I found out that on the manifest there was a reference to the TestePHP2 that I hadn't changed before. for reference, this was the line on the Android Manifest XML:
> <activity android:name="com.testedeacesso2.www.TesteTempo01"
> android:label="#string/app_name">
After this, I keep getting a NullPointerException because the class can't find the main class! I've searched through the whole code but I found no other references to the old class. Have I forgotten something? Do I need to alter something else to change this class' name? Or the import will only work with the original class names?
You said the package was 'com.testedeacesso.www', but when you reference the class, its 'com.testedeacesso2.www'. I'm guessing you have a problem with class/package references.

Categories

Resources