Android studio project could not find android.view.View - android

My Android project show that it is not able to find the android.view.View class but still it is being compiled and run on simulator and devices.
apart from android.view.View All other class of the package is accessible like
This is not available ==> import android.view.View;
this is available => import android.view.ViewGroup;
I have tried many things like Clean, Rebuild, restart and Invalidate cache and restart but not fixed this issue.
Please check the code and help me to fix this issue.
import android.view.View;
public class AppSettingsActivity extends BaseActivity implements View.OnClickListener, AdListener {
//Other objects
private static final String TAG = AppSettingsActivity.class.getSimpleName();
//Data objects
// //Design
private LinearLayout banner_container;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
initViews();
}
private void initViews() {
//Actionbar init
//Action bar
TextView idTvTitle = findViewById(R.id.idTvTitle);
findViewById(R.id.idTvSelectDefaultActivity).setOnClickListener(this);
findViewById(R.id.idTvSelectAppLang).setOnClickListener(this);
findViewById(R.id.idIvBack).setOnClickListener(this);
findViewById(R.id.idTvCalcSetting).setOnClickListener(this);
//Set data
//Set Actionbar Title
idTvTitle.setText(R.string.app_settings_text);
//Load Facebook ads
banner_container = findViewById(R.id.banner_container);
if (fbAdView != null) {
banner_container.addView(fbAdView);
fbAdView.loadAd();
fbAdView.setAdListener(this);
logs.e(TAG, "Face book load add called....");
}
int selectedLanguage=SessionManagement.getIntValue(AppSettingsActivity.this, AppConstant.SELECTED_LANG, AppConstant.INT_ONE);
int selectedScreen=SessionManagement.getIntValue(AppSettingsActivity.this, AppConstant.DEFAULT_SCREEN_INDEX, AppConstant.INT_ONE);
String[] languages = getResources().getStringArray(R.array.language);
String[] screens = getResources().getStringArray(R.array.screens);
((TextView)findViewById(R.id.idTvSelectDefaultActivity)).setText(screens[selectedScreen]);
((TextView)findViewById(R.id.idTvSelectAppLang)).setText(languages[selectedLanguage]);
}

I am giving this answer to my question.
I simply uninstall the Android studio and reinstall it. My previous Android studio was running with 3.5 version (Latest) and the fresh install Android studio version was also 3.5 so there was no versioning difference in it. But I don't know some How issue fixed when I reinstall AS.
After half an hour of searching, I could not found a solution that can fix my issue. Then I pass the same code to other PC and it was working well on that PC.
So This is final that no issue in the source code.
Then 2nd suspect is the android studio
I uninstall Android Studio and install it again, it took me 1 hour to set-up and make the code workable but it saves 30GB of my hard disk space so it was worth it.
But still, Android studio manage SDK and build tools very badly

Related

visual studio android import cant resolved after update

I updated Visual Studio, then my Android project had errors such as import could not be resolved. It could not be resolved to a text type. The type could not be resolved. Then I created a new project with the same settings. However, it had the same errors. It does not work because of the code, but maybe it knows who knows the code here.
package com.Android2;
import android.app.Activity;
import android.widget.TextView;
import android.os.Bundle;
public class Android2 extends Activity
{
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
/* Create a TextView and set its text to "Hello world" */
TextView tv = new TextView(this);
tv.setText("Hello World!");
setContentView(tv);
}
}
There is no problem with your code or imports...
I know it is hard work and a serious change when it comes to shortcuts, menus, overview, etc., but i would suggest to use android studio instead of visual studio if you only write android apps in java. I used visual studio too and switched to android studio.
Android Studio will give you more comfort than every other ide in programming android apps in java!
I know this problems you wrote about very well and had the same. Sry that this isnt a really answer of your problem and does not solves your concrete problem.
Tips for solving, you probably already know:
reboot your pc and visual studio if you not already did
delete caches or other from visual studio
rebuilt/clean your project
not easy, but reinstall visual studio
I hope i could help anyway!

Is Androids new Jack compiler really that slow?

On some of my Android projects I see that building got quite slow since using the new Jack compiler. I need it to use Java 8 features like lambdas.
But the long building time is a bit disturbing. So I set up a new Android project. It contains just a MainActivity with one button which reacts on your click.
package de.xappo.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
Button button;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(final View view) {
Toast.makeText(MainActivity.this, "Button clicked!", Toast.LENGTH_LONG).show();
}
});
}
}
There is nothing else except from the layout file which just contains a a TextView and a Button within a RelativeLayout.
As you can see in the picture all the jack gradle tasks together take about 75 seconds. Is this normal? This hole example app builds in less than 22 seconds without jack. So is this big difference normal?
I already managed Java heap size within my gradle.properties file:
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Is there still any thing to do to improve jack compiling performance? Or do you know about any updates planned on jack to improve building time?
As per this announcement, the Jack toolchain on Android is deprecated and java8 support will be directly integrated into Android's standard javac and dx toolchain. I switched to Jack for java8 support, but then transitioned to retrolambda because Jack was so slow.

"...cannot be resolved to type" error message; no method suggestions in Eclipse

Ok guys I've got a question that for the life of me I cannot get figured out. I'm using Eclipse, and I've got the Android ADT pluging all installed, the program configured with the Android SDK path, and all the extra SDK parts downloaded (Google API's, SDK Platforms, System Images). Here is my problem: whenever I go to access a method from a certain object, Eclipse gives no method "suggestions" like it usually does. I'm probably not explaining this the best, so I've attached a screenshot that kind of illustrates the issue.
public class StartingPoint extends Activity {
int counter;
Button add;
Button sub;
TextView display;
//putting add.whatever here doesn't work
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_starting_point);
counter = 0;
add = (Button) findViewById(R.id.buttonAdd);
sub = (Button) findViewById(R.id.buttonSub);
display = (TextView) findViewById(R.id.textView1);
add.setOnClickListener(new View.OnClickListener() {
//putting add.whatever here doesn't show suggestions either.
I've tried everything I can think of to get it working, deleting & reinstalling eclipse, deleting everything Android from with Eclipse and going through all the SDK setup again, changing my workspace, creating an entirely new project, deleting the Eclipse preference file, endless Googling, resetting & altering settings, and I can't for the life of me figure out what's causing this. Any ideas? Thanks!

Android activity & import issue

Trying out some android programming that has gone fine up until this point. I'm getting the following errors:
Activity cannot be resolved to a type
The import Activity cannot be resolved
on the top two imports (activity and bundle) of the following class:
package com.example.sqlite;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
public class Input extends Activity {
private EditText txtTitle;
private EditText txtURL;
private Button btnOK;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.input);
txtTitle = (EditText) findViewById(R.id.editText1);
txtURL = (EditText) findViewById(R.id.editText2);
btnOK = (Button) findViewById(R.id.button1);
}
}
I've done the standard ctrl + shift + O, which does automatically add these imports but the errors remain. I've also rebuilt it over and over with no effect.
Ca anyone see were I'm going wrong here?
Do right click on the project node in Eclipse and select Android Tools->Fix Project Properties. It looks like you are missing link to your Android libraries. Good way to check on that is to open properties-> Java build path -> Libraries and verify that Android link is there. If not - do Properties->Android and select project target you would like to use
You may occasionally see strange erros if any of your XML files fail to build. Check your console to see if any of your layout or resources have errors. Do the following:
Project > Clean
If this does not fix it, verify that pour souce actually exists in the project path:
com.example.sqlite
Check your manifest xml if the activity is included.. This can sometimes cause the error.

Issue observed with Android app developed using phonegap

I have developed Android applicationusing Phonegap framework with Eclipse pulgin. am not gettting any error in Eclipse but when i'm running the app am able to see the blank app screen.So can someone help me out this issue..
Sample app developed using this link
Please comment asap..
Code:
Java File ----------
package com.phonegap;
import com.phonegap.*;
import android.os.Bundle;
public class HelloworldActivity extends DroidGap
{
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_assets/www/helloworld.html");
}
}
The problem is in your loadUrl, you should use:
super.loadUrl("file:///android_asset/index.html"); // Singular android_asset, not assets

Categories

Resources