READ ONLY EDIT DOWN!!
Okay, so I can't develop nothing as my Android Studio decided to. My all project is full of errors, unknown errors caused by Android Studio.
note: my files are correct, it is an other problem because even if I will import something from google codes it will have errors.
When I import a project everything's fine, but then after indexing and such things, all sudden everything is red and shouldn't be.
My errors for example are :
Code:
button1.setOnLongClickListener(new View.OnLongClickListener() {
....
....
}
Well shouldn't be error but :
Code:
cannot resolve symbol setOnLongClickListener
Another example:
Code:
button1=(Button) findViewById(R.id.button1);
I used this exact code for other button, seems right, I always using this line, it was fine until my Android Studio decided to give me some hard time, this line is full by errors and they are:
Code:
Unknown class: 'button1' , invalid method declaration; return type required, missing method body, or declare abstract
and there are like 20 errors that shouldn't be, things I tried:
1.deleting iml files , .idea folder - worked for a while but now it happened again and it doesn't fix it.
2.reinstalling android studio and then importing project.
3.upgrading android studio version to 1.3
4.restarting my pc.
5.importing project to an other pc, happened after a while.
6.Invalidate caches/ restart.
7.Changing module in project structure - I changed it back to how it was (it didn't help) and I think it caused the manifest error down..
My Module:app build.gradle:
Code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "firstappdevelopments.david.reactiontime"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}
Also I noticed now, my Manifest file as an error in
Code:
android:name=".MainActivity"
says it has no default structure. something like this. here is the full normal code:
Code:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
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>
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
</manifest>
Please, if someone knows what is the problem or what can I else do, just say, and I am sorry about my English, thank you all.
EDIT!!!:
I deleted this lines:
Code:
connect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bluetooth = BluetoothAdapter.getDefaultAdapter();
if (bluetooth != null) {
if (bluetooth.isEnabled()) {
bluetooth.startDiscovery();
Set<BluetoothDevice> bondedSet = bluetooth.getBondedDevices();
if(bondedSet.size() > 0){
for(BluetoothDevice device : bondedSet){
newDevicesListView.setVisibility(View.VISIBLE);
mArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
}else{
mArrayAdapter.add("No Devices");
}
}
} else {
textview.setText("bluetooth is disabled, enabling.");
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, RESULT_OK);
}
} else{
textview.setText("Bluetooth is not supported.");
}
}
});
AND SUDDENLY ALL THE ERRORS DISSAPPEARED , ANY IDEAS? - The errors was in other lines..
Related
xposed framework handleLoadPackage、 initZygote method not execute.
manifest configuration :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="htt:://schemas.android.com/apk/res/android"
package="com.android.xdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<!-- xposed -->
<meta-data
android:name="xposeddescription"
android:value="xposed test demo" />
<meta-data
android:name="xposedmodule"
android:value="true" />
<meta-data
android:name="xposedminversion"
android:value="54" />
<activity
android:name="com.android.xdemo.MainActivity"
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>
------------------------
xposed_init configuration :
com.android.xdemo.XDemoMain
---------------------
XDemoMain class :
package com.android.xdemo;
import java.io.File;
import android.os.Environment;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.callbacks.XC_LoadPackage.Lo adPackageParam;
public class XDemoMain implements IXposedHookLoadPackage, IXposedHookZygoteInit {
@override
public void initZygote(StartupParam startupParam) throws Throwable {
try {
String sd = Environment.getExternalStorageDirectory().getAbsol utePath();
new File(sd, "test").createNewFile();
} catch (Exception e) {
}
}
@override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
try {
String sd = Environment.getExternalStorageDirectory().getAbsol utePath();
new File(sd, "demo").createNewFile();
} catch (Exception e) {
}
}
}
------------------------------------------------------
These are configured according to the official document, Xposed framework can also be installed on the phone looking for in the module is handleLoadPackage, initZygote these two methods have not been called, did not seem to come in this class, there is not a configuration mistake, please great God pointing
Hello every one,
please help me
showing the already loaded url and not showing the presently loading URL
Main activity
-------------------------
package com.example.amit.myapplication;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
private WebView mWebView;
@override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
mWebView = new WebView(this);
mWebView.loadUrl("**********");
mWebView.setWebViewClient(new WebViewClient() {
@override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
this.setContentView(mWebView);
}
@override
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
mWebView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
-----------------------------------------------------------------------
Activity main
-----------------
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="linknot avilible"
xmlns:tools="not available"
android:layout_width="match_parent"
android:layout_height="match_parent"
androidaddingBottom="@dimen/activity_vertical_margin"
androidaddingLeft="@dimen/activity_horizontal_margin"
androidaddingRight="@dimen/activity_horizontal_margin"
androidaddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.amit.myapplication.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<WebView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/mwebView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
-----------------------------------------------
AndroidManifest
--------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="link not avaible"
package="com.example.amit.myapplication">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
------------------
what could be the problem ?
thanks alot for answers
Can you please explain it better? What do you mean by already loaded url and by presently loading url?
Hi
Thanks for replay,
I mean after caple days the main page in app dont refresh.
Things have been going good within the app and I have been running the app on my phone or tablet throughout the build with no issues.
All of a sudden, I have errors within the Manifest and it will not run/load on to my phone or tablet any longer.
I have googled for answers and "fixes" but have not been able to make any progress, I hope that I can get help here and get everything back in working order so I can move forward with the build.
The only thing I can think of that I did prior to seeing the errors was I may have "Alt+Enter" and chose API Google by accident at one point.
I went back and deleted all the Google things from my manifest and so forth. It was at this point I noticed the errors within the manifest.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.z.flowmaster">
<application ---------------------------> App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW intent filler.
android:allowBackup="true" --------------------------------------------- On SDK Version 23 and up, your app data will be automatically backed up and restored on app install. Consider adding the
android:icon="@mipmap/ic_launcher" ---------------------------------attribute android:fullBackupContent to specify an @xml resource which configures which files to backup. More info at ............
android:label="Backflow Master"
android:supportsRtl="true"
android:theme="@style/AppTheme" />
<activity android:name=".ActivityHome"> ------------> Element activity not allowed here / This inspection highlights unallowable XML ......
<intent-filter> --------------> Element intent-filter is not allowed here / This inspection highlights unallowable XML tags in Android rsource files & AndroidManifest.xml
<action android:name="android.intent.action.MAIN" /> --------> Element action is not allowed here / This inspection highlights unallowed XML .....
<category android:name="android.intent.category.LAUNCHER" /> --------> Element catagory is not allowed here / This inspection highlights ......
</intent-filter> ----------> Element intent-filter is not allowed here / This inspection highlights unallowable XML tags in Android resource files & AndroidMainfest.xml
</activity> --------------------------> says same as below "activity"
<activity android:name=".TestingMain" /> ---------------> "activity" is highlighted "Element activity is not allowed here."
<activity android:name=".TestingRP" /> --------------------------- This inspection highlights unallowed XML tags in Android resource files and AndroidManifest.xml
<activity android:name=".TestingDC" />
<activity android:name=".TestingPVB" />
<activity android:name=".TestingSRVB" />
<application/>
</manifest>
Assuming you are using AS, under the build tab in Android Studio, try clicking on "Clean" and then do a "Re-build"
Yes, I am using Android Studio 2.1.1
* However, I will note that at the time the error first occurred I was using 1.5.1 I believe.
After getting the error and trying a few things to rid the error, I finally just uninstalled the full program and reinstalled (new version) Android Studio.
I think I reinstalled everything correctly but I could have left something out or something is out of place I guess.
I feel like I have checked to make sure the reinstall was done correctly but that's not saying I didn't miss something...
After going to >Build >Clean Project I receive the following in my Messages "Gradle Build":
! A problem occurred evaluating project ':app'.
>Failed to apply plugin [id'com.android.application']
>Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in C:/Users .....
! BUILD FAILED
! Total time: 0.611 secs
! 1 error
! 0 warnings
! See complete output in console
When I "Rebuild" it gives me the same as above.
Can you post the contents of your Gradle properties files here. I think this is where the issue lies "Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in C:/Users ....."
-Project-
v Flowmaster
v app
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.z.flowmaster"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0-alpha1' ----------> This support library should not use a different version (24) than the compileSdkVersion(23) / There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)
}
-Project-
v Flowmaster
v gradle
v wrapper
- gradle-wrapper.jar
v gradle-wrapper.properties
#Wed Oct 21 11:34:03 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
-Project-
v Flowmaster
v gradle
- build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
-Project-
v Flowmaster
v gradle
- build.properties
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
I'm trying to create a widget that will show the icon's of some app's installed on the device.
I manage to get a list of packages installed in the device, but i don't know how to get the icon from these.
I have this in my activity:
Code:
final static List<String> pacote_app = new ArrayList<String>();
final List<ApplicationInfo> apps = pm.getInstalledApplications(0);
for (ApplicationInfo app : apps) {
//checks for flags; if flagged, check if updated system app
if ((app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
// installedApps.add(app);
//it's a system app, not interested
} else if ((app.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
//Discard this one
//in this case, it should be a user-installed app
} else {
String pacote = (String) app.packageName; //NOME DOS PACOTES
pacote_app.add(pacote);
}
}
// 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();
WidgetViewsFactory
Code:
import static com.example.magcr23.mywidget.LoremActivity.pacote_app;
public class WidgetViewsFactory implements RemoteViewsService.RemoteViewsFactory {
Context context;
private Context ctxt=null;
private int appWidgetId;
public WidgetViewsFactory(Context ctxt, Intent intent) {
this.ctxt=ctxt;
appWidgetId=intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID);
}
@Override
public void onCreate() {}
@Override
public void onDestroy() {
// no-op
}
@Override
public int getCount() {
return(pacote_app.size());
}
@Override
public RemoteViews getViewAt(int position) {
RemoteViews row=new RemoteViews(ctxt.getPackageName(),
R.layout.list_item);
//FILL LIST
row.setTextViewText(android.R.id.text1, pacote_app.get(position));
//SEND WORD TO ACTIVITY
Intent i=new Intent();
Bundle extras=new Bundle();
extras.putString(WidgetProvider.EXTRA_WORD, pacote_app.get(position));
i.putExtras(extras);
row.setOnClickFillInIntent(android.R.id.text1, i);
//--------------
return(row);
}
@Override
public RemoteViews getLoadingView() {
return(null);
}
@Override
public int getViewTypeCount() {
return(1);
}
@Override
public long getItemId(int position) {
return(position);
}
@Override
public boolean hasStableIds() {
return(true);
}
@Override
public void onDataSetChanged() {
// no-op
}
}
WidgetProvider
Code:
public class WidgetProvider extends AppWidgetProvider{
public static String EXTRA_WORD=
"com.commonsware.android.appwidget.lorem.WORD";
@Override
public void onUpdate(Context ctxt, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
for (int i=0; i<appWidgetIds.length; i++) {
Intent svcIntent=new Intent(ctxt, WidgetService.class);
svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
RemoteViews widget=new RemoteViews(ctxt.getPackageName(),
R.layout.novo_widget);
widget.setRemoteAdapter(appWidgetIds[i], R.id.listagem,
svcIntent);
Intent clickIntent=new Intent(ctxt, LoremActivity.class);
PendingIntent clickPI=PendingIntent
.getActivity(ctxt, 0,
clickIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
widget.setPendingIntentTemplate(R.id.listagem, clickPI);
appWidgetManager.updateAppWidget(appWidgetIds[i], widget);
}
super.onUpdate(ctxt, appWidgetManager, appWidgetIds);
}
}
WidgetService
Code:
public class WidgetService extends RemoteViewsService {
@Override
public RemoteViewsFactory onGetViewFactory(Intent intent) {
return(new WidgetViewsFactory(this.getApplicationContext(),
intent));
}
Layout
Code:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/widget_margin"
android:orientation="horizontal">
<ListView
android:id="@+id/listagem"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
ListView Layout
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:paddingLeft="6dip"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textColor="#000"
/>
</LinearLayout>
(Whoops, topic a bit old, haven't see the date)
Hi,
You should give a look to PackageItemInfo methods, especially loadIcon (https://developer.android.com/refer...ml#loadIcon(android.content.pm.PackageManager)
In your code:
Code:
final static List<String> pacote_app = new ArrayList<String>();
final List<ApplicationInfo> apps = pm.getInstalledApplications(0);
for (ApplicationInfo app : apps) {
//checks for flags; if flagged, check if updated system app
if ((app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
// installedApps.add(app);
//it's a system app, not interested
} else if ((app.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
//Discard this one
//in this case, it should be a user-installed app
} else {
String pacote = (String) app.packageName; //NOME DOS PACOTES
pacote_app.add(pacote);
// I guess you want to get your icon here
Drawable packageIcon = app.loadIcon(pm);
}
}
To show it, the easiest might be to add an ImageView and call setImageDrawable
Good luck!
Hi together
If i create a signed bundle release, the debuger adds the android studio release number in the AndroidManifest.xml file and throws an error
i know there should not been any numbers in the package name, but why adds AS this every time?
here are the error message:
C:\Users\dev\AndroidStudioProjects\newsapp\app\build\intermediates\bundle_manifest\release\AndroidManifest.xml:2: AAPT: error: attribute 'package' in <manifest> tag is not a valid Android package name: 'com.acme.newsapp.1.4.30'.
The AndroidManifest.xml in the project folder:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.acme.newsapp">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@Mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@Mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activ..
The build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
In the debug version this doesnt happen, only on the signed release
my Android Studio Version is the 4.1.2
Anyone a idea why this happens?