I am trying to extract three separate strings from:
https://taxtest.navajocountyaz.gov/Pages/WebForm1.aspx?p=1&apn=103-03-122
The owners names: Johnson Tommy A & Nell H Cprs
The owners street address: 133 Maricopa Dr
The owners city, state and zip code, as one string: Winslow AZ 86047-2013
I tried the following code:
import com.gargoylesoftware.htmlunit.*;
import com.gargoylesoftware.htmlunit.html.*;
import com.gargoylesoftware.htmlunit.javascript.*;
import java.io.*;
public class PropertyOwner {
public static void PropertyOwner () {
try (final WebClient webClient = new WebClient()) {
System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog", "fatal");
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.OFF);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
webClient.getOptions().setCssEnabled(false);
webClient.setJavaScriptErrorListener(new SilentJavaScriptErrorListener());
webClient.setCssErrorHandler(new SilentCssErrorHandler());
HtmlPage page = webClient.getPage("http://taxtest.navajocountyaz.gov/Pages/WebForm1.aspx?p=1&apn=103-03-122");
webClient.waitForBackgroundJavaScriptStartingBefore(10000);
page = (HtmlPage) page.getEnclosingWindow().getEnclosedPage();
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.setJavaScriptErrorListener(new SilentJavaScriptErrorListener());
HtmlTable pnlGridView_nextYear = (HtmlTable) page.getElementById("pnlGridView_nextYear");
HtmlTableDataCell ownershipCell = (HtmlTableDataCell) pnlGridView_nextYear.getCellAt(0,0);
String ownershipCellAsText = ownershipCell.toString();
HtmlElement onwershipElement = (HtmlElement) page.getElementById("lblOwnership_NextYear");
System.out.println("ownershipCellAsText = " + ownershipCellAsText);
System.out.println("onwershipElement.getTextContent() = " + onwershipElement.getTextContent());
}
catch (Exception e) {
System.out.println("Error: "+ e);
}
}
public static void main(String[] args) {
File file = new File("validParcelIDs.txt");
PropertyOwner();
}
}
I then used the following two commands:
> javac -classpath ".:/opt/htmlunit_2.69.0/*" PropertyOwner.java
> java -classpath ".:/opt/htmlunit_2.69.0/*" PropertyOwner
And got the following output:
ownershipCellAsText = HtmlTableDataCell[<td style="border:solid 1px black;">]
onwershipElement.getTextContent() = Johnson Tommy A & Nell H Cprs133 Maricopa DrWinslow AZ 86047-2013
As you can see, onwershipElement.getTextContent() is fairly close to what I want. Except that it removed the line breaks from the HtmlElement.
I tried the following solution, which was proposed over 8 years ago:
Java getting text content from an element to include line breaks
by adding just three lines of code to my program. The following three (non consecutive) lines:
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
.....
WebView webView = new WebView();
And that gave me the following compiling error:
achab#HP-Envy [Navajo] $javac -classpath ".:/opt/htmlunit_2.69.0/*" PropertyOwner.java
PropertyOwner.java:15: error: cannot find symbol
WebView webView = new WebView();
^
symbol: class WebView
location: class PropertyOwner
PropertyOwner.java:15: error: cannot find symbol
WebView webView = new WebView();
^
symbol: class WebView
location: class PropertyOwner
2 errors
So, it seems like that solution is outdated. The 2.69.0 release of HtmlUnit was released January 5, 2023.
Before that. I had tried 2.47.1 release of HtmlUnit, which was released about two years ago. With the same two problems described above: failure to preserve line breaks in the first version of the code, and not finding the symbol WebView in the second version of the code.
What do I need to change in order to get the three separate strings that I want?
Instead of onwershipElement.getTextContent() use onwershipElement.asNormalizedText() .
This question already has answers here:
What does a "Cannot find symbol" or "Cannot resolve symbol" error mean?
(18 answers)
Closed 1 year ago.
I was trying to do what was proposed here: Converting Image to Color array
The code that I copied:
BufferedImage bi = ImageIO.read( new File( "image.png" ) );
int[] data = ( (DataBufferInt) bi.getRaster().getDataBuffer() ).getData();
for ( int i = 0 ; i < data.length ; i++ ) {
Color c = new Color(data[i]);
// RGB is now accessible as
c.getRed();
c.getGreen();
c.getBlue();
}
I changed "image.png" to "BA 0091.jpg" in my code.
Code:
public class BANCPU{
public static void main(String[] Ugh){
BufferedImage bi = ImageIO.read( new File( "BA 0091.jpg" ) );
int[] data = ( (DataBufferInt) bi.getRaster().getDataBuffer() ).getData();
for ( int i = 0 ; i < data.length ; i++ ) {
Color c = new Color(data[i]);
// RGB is now accessible as
c.getRed();
c.getGreen();
c.getBlue();
}
}
}
Errors that I got:
File: C:\Users\Ben\Desktop\prgm clas\java junk\BANCPU.java [line: 3]
Error: cannot find symbol
symbol: class BufferedImage
location: class BANCPU
File: C:\Users\Ben\Desktop\prgm clas\java junk\BANCPU.java [line: 3]
Error: cannot find symbol
symbol: variable ImageIO
location: class BANCPU
File: C:\Users\Ben\Desktop\prgm clas\java junk\BANCPU.java [line: 3]
Error: cannot find symbol
symbol: class File
location: class BANCPU
File: C:\Users\Ben\Desktop\prgm clas\java junk\BANCPU.java [line: 4]
Error: cannot find symbol
symbol: class DataBufferInt
location: class BANCPU
File: C:\Users\Ben\Desktop\prgm clas\java junk\BANCPU.java [line: 6]
Error: cannot find symbol
symbol: class Color
location: class BANCPU
File: C:\Users\Ben\Desktop\prgm clas\java junk\BANCPU.java [line: 6]
Error: cannot find symbol
symbol: class Color
location: class BANCPU
You will need to import a few libraries to make that program work.
import java.awt.image.*;
import java.awt.*;
import java.io.*;
import javax.imageio.*;
Add those lines to the top of your program and it should work.
I'm trying to migrate my build tool from maven to bazel. I have a java/grpc with a proto file, if I build it with maven all is good, but with bazel I keep facing a problem that happens on the grpc. Maybe my bazel BUILD/WORKSPACE file is not configured properly, I'm not too sure. Any help would be appreciated!
Here is my WORKSPACE file:
load("#bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "3.0"
RULES_JVM_EXTERNAL_SHA = "62133c125bf4109dfd9d2af64830208356ce4ef8b165a6ef15bbff7460b35c3a"
http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)
http_archive(
name = "bazel_skylib",
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
],
)
load("#bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
http_archive(
name = "rules_proto",
sha256 = "73ebe9d15ba42401c785f9d0aeebccd73bd80bf6b8ac78f74996d31f2c0ad7a6",
strip_prefix = "rules_proto-2c0468366367d7ed97a1f702f9cd7155ab3f73c5",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/2c0468366367d7ed97a1f702f9cd7155ab3f73c5.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/2c0468366367d7ed97a1f702f9cd7155ab3f73c5.tar.gz",
],
)
load("#rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()
http_archive(
name = "com_google_protobuf",
sha256 = "e11f901c62f6a35e295b7e9c49123a96ef7a47503afd40ed174860ad4c3f294f",
strip_prefix = "protobuf-3.10.0",
url = "https://github.com/protocolbuffers/protobuf/releases/download/v3.10.0/protobuf-all-3.10.0.tar.gz",
)
http_archive(
name = "googleapi",
sha256 = "51849d3ef693c88eb7692875eb444ef7131502e3fa200f25fc0a37b1e7e55ab5",
strip_prefix = "googleapis-a111a53c0c6722afcd793b64724ceef7862db5b9",
url = "https://github.com/googleapis/googleapis/archive/a111a53c0c6722afcd793b64724ceef7862db5b9.zip",
)
load("#com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
load("#rules_jvm_external//:specs.bzl", "maven")
load("#rules_jvm_external//:defs.bzl", "artifact", "maven_install")
maven_install(
artifacts = [
"com.google.cloud:google-cloud-pubsub:1.92.0",
"com.google.cloud:google-cloud-storage:1.98.0",
"io.grpc:grpc-netty-shaded:1.23.0",
"io.grpc:grpc-protobuf:1.23.0",
"io.grpc:grpc-stub:1.23.0",
"mysql:mysql-connector-java:8.0.17",
"com.google.cloud.sql:mysql-socket-factory-connector-j-8:1.0.15",
"com.zaxxer:HikariCP:3.3.1",
"com.google.inject:guice:4.2.2",
"jaxen:jaxen:1.2.0",
"org.dom4j:dom4j:2.1.1",
"org.slf4j:slf4j-simple:2.0.0-alpha1",
"org.slf4j:slf4j-api:2.0.0-alpha1",
"log4j:log4j:1.2.17",
"com.google.code.gson:gson:2.8.6",
"junit:junit:4.13-beta-3",
"com.google.protobuf:protobuf-java:3.0.0",
"com.google.protobuf:protobuf-java-util:3.0.0",
],
override_targets = {
"com.google.protobuf:protobuf-java": "#com_google_protobuf//:protobuf_java",
},
maven_install_json = "//:maven_install.json",
generate_compat_repositories = True,
repositories = [
"https://jcenter.bintray.com",
],
)
load("#maven//:defs.bzl", "pinned_maven_install")
pinned_maven_install()
load("#maven//:compat.bzl", "compat_repositories")
compat_repositories()
maven_install(
artifacts = [
maven.artifact(
group = "com.google.api.grpc",
artifact = "proto-google-common-protos",
version = "1.16.0",
exclusions = [
maven.exclusion(
group = "com.google.protobuf",
artifact = "protobuf-java"
)
]
)
],
maven_install_json = "//:maven_install.json",
generate_compat_repositories = True,
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
load("#maven//:defs.bzl", "pinned_maven_install")
pinned_maven_install()
load("#maven//:compat.bzl", "compat_repositories")
compat_repositories()
Here is my BUILD file:
package(default_visibility = ["//visibility:public"])
load("#rules_proto//proto:defs.bzl", "proto_library")
proto_library(
name = "account",
srcs = glob(["src/main/proto/account.proto"]),
deps = ["#googleapi//google/api:annotations_proto"],
)
java_proto_library(
name = "account_proto_java",
deps = [":account"],
)
java_library(
name = "AccountService",
srcs = glob(["src/main/java/**/*.java"]),
resources = glob(["src/main/resources/**"]),
deps = [
"#maven//:com_google_cloud_google_cloud_pubsub",
"#maven//:com_google_cloud_google_cloud_storage",
"#maven//:io_grpc_grpc_netty_shaded",
"#maven//:io_grpc_grpc_protobuf",
"#maven//:io_grpc_grpc_stub",
"#maven//:mysql_mysql_connector_java",
"#maven//:com_google_cloud_sql_mysql_socket_factory_connector_j_8",
"#maven//:com_zaxxer_HikariCP",
"#maven//:com_google_inject_guice",
"#maven//:jaxen_jaxen",
"#maven//:org_dom4j_dom4j",
"#maven//:org_slf4j_slf4j_simple",
"#maven//:org_slf4j_slf4j_api",
"#maven//:log4j_log4j",
"#maven//:com_google_code_gson_gson",
"#maven//:junit_junit",
"#maven//:com_google_guava_guava",
"#maven//:io_grpc_grpc_api",
"#maven//:com_google_protobuf_protobuf_java",
"#maven//:com_google_protobuf_protobuf_java_util",
":account_proto_java",
],
)
I finally run that command: docker run --rm -v /${PWD}:${PWD} -w /${PWD} l.gcr.io/google/bazel:latest build ///...
Some issues that occur:
I always seem to get an error when it's downloading the resources. Here is an example: WARNING: Download from https://maven.google.com/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
For some reason, it doesn't stop there when the 404 appears, towards the end when it comes to build the proto section. I get this error:
ERROR: /c/Users/<username>/projects/Ecommerce-Account-Microservice/BUILD:16:1: Building libAccountService-class.jar (198 source files) failed (Exit 1)
src/main/java/com/app/account/GRPCClient.java:7: error: cannot find symbol
import com.app.account.services.AccountServiceGrpc;
^
symbol: class AccountServiceGrpc
location: package com.app.account.services
src/main/java/com/app/account/GRPCClient.java:20: error: package AccountServiceGrpc does not exist
private final AccountServiceGrpc.AccountServiceBlockingStub blockingStub;
^
src/main/java/com/app/account/server/services/AccountService.java:24: error: cannot find symbol
import com.app.account.services.AccountServiceGrpc;
^
symbol: class AccountServiceGrpc
location: package com.app.account.services
src/main/java/com/app/account/server/services/AccountService.java:39: error: package AccountServiceGrpc does not exist
public class AccountService extends AccountServiceGrpc.AccountServiceImplBase {
^
src/main/java/com/app/account/GRPCClient.java:28: error: cannot find symbol
blockingStub = AccountServiceGrpc.newBlockingStub(channel);
^
symbol: variable AccountServiceGrpc
location: class GRPCClient
src/main/java/com/app/account/server/GrpcServer.java:28: error: no suitable method found for addService(AccountService)
.addService(AccountService.getInstance())
^
method ServerBuilder.addService(ServerServiceDefinition) is not applicable
(argument mismatch; AccountService cannot be converted to ServerServiceDefinition)
method ServerBuilder.addService(BindableService) is not applicable
(argument mismatch; AccountService cannot be converted to BindableService)
where CAP#1 is a fresh type-variable:
CAP#1 extends ServerBuilder<CAP#1> from capture of ?
src/main/java/com/app/account/server/services/AccountService.java:57: error: method does not override or implement a method from a supertype
#Override
^
src/main/java/com/app/account/server/services/AccountService.java:65: error: method does not override or implement a method from a supertype
#Override
^
src/main/java/com/app/account/server/services/AccountService.java:223: error: method does not override or implement a method from a supertype
#Override
^
src/main/java/com/app/account/server/services/AccountService.java:273: error: method does not override or implement a method from a supertype
#Override
^
INFO: Elapsed time: 373.098s, Critical Path: 44.04s
INFO: 358 processes: 353 processwrapper-sandbox, 5 worker.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
I'm not too sure what is going on or what I'm doing wrong at that point, that's why I'm showing all the code.
Thanks a lot!
Mark
If you want to use multiple maven_install declarations, you need unique names for each of them. See documentation here.
I always seem to get an error when it's downloading the resources. Here is an example: WARNING: Download from https://maven.google.com/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
It looks like you don't actually use maven.google.com for any of the artifacts. Remove that from your maven_install.repositories lists and re-run artifact pinning for them.
For the missing GRPC classes, it looks like you're missing a java_grpc_library between java_library and java_proto_library. Example.
I have a small project that I finished couple of months ago, and left it on my git account.
Today I have downloaded this project locally and tried to launch, but got such error
Error:(18, 19) error: package R does not exist
I tried clean and rebuild , but it doesn't helped
my log look like this
Information:Gradle tasks [:app:assembleDebug]
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java
Error:(7, 39) error: cannot find symbol class R
Error:(18, 19) error: package R does not exist
Error:(21, 79) error: package R does not exist
Error:(22, 79) error: package R does not exist
Error:(31, 17) error: package R does not exist
Error:(176, 51) error: package R does not exist
Error:(178, 53) error: package R does not exist
Error:(179, 51) error: package R does not exist
Error:(181, 53) error: package R does not exist
Error:(182, 51) error: package R does not exist
Error:(184, 53) error: package R does not exist
Error:(185, 51) error: package R does not exist
Error:(187, 53) error: package R does not exist
Error:(189, 51) error: package R does not exist
Error:(192, 62) error: package R does not exist
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 2.421 secs
Information:98 errors
Information:0 warnings
Information:See complete output in console
my compiler error output look like this
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:7: error: cannot find symbol
import com.example.aleksey.videoviewer.R;
^
symbol: class R
location: package com.example.aleksey.videoviewer
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:17: error: cannot find symbol
import com.example.aleksey.videoviewer.R;
^
symbol: class R
location: package com.example.aleksey.videoviewer
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:22: error: cannot find symbol
import com.example.aleksey.videoviewer.R;
^
symbol: class R
location: package com.example.aleksey.videoviewer
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentVideo.java:6: error: cannot find symbol
import com.example.aleksey.videoviewer.R;
^
symbol: class R
location: package com.example.aleksey.videoviewer
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:15: error: cannot find symbol
import com.example.aleksey.videoviewer.R;
^
symbol: class R
location: package com.example.aleksey.videoviewer
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivitySplash.java:12: error: cannot find symbol
import com.example.aleksey.videoviewer.R;
^
symbol: class R
location: package com.example.aleksey.videoviewer
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:7: error: cannot find symbol
import com.example.aleksey.videoviewer.R;
^
symbol: class R
location: package com.example.aleksey.videoviewer
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:18: error: package R does not exist
setTheme(R.style.AppTheme_Dark);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:21: error: package R does not exist
Preference prefShareKey = (Preference) findPreference(getString(R.string.pref_share_key));
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:22: error: package R does not exist
Preference prefRateReviewKey = (Preference) findPreference(getString(R.string.pref_rate_review_key));
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:31: error: package R does not exist
return R.xml.pref_about;
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:36: error: package R does not exist
if(preference.getKey().equals(getString(R.string.pref_share_key))) {
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:40: error: package R does not exist
getString(R.string.subject));
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:41: error: package R does not exist
shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.message) +
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:42: error: package R does not exist
" " + getString(R.string.googleplay_url));
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:43: error: package R does not exist
startActivity(Intent.createChooser(shareIntent, getString(R.string.share_to)));
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:44: error: package R does not exist
}else if(preference.getKey().equals(getString(R.string.pref_rate_review_key))) {
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:47: error: package R does not exist
getString(R.string.googleplay_url)));
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:56: error: package R does not exist
overridePendingTransition(R.anim.open_main, R.anim.close_next);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:56: error: package R does not exist
overridePendingTransition(R.anim.open_main, R.anim.close_next);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:61: error: package R does not exist
setContentView(R.layout.activity_home);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:63: error: package R does not exist
layoutList = (FrameLayout) findViewById(R.id.fragment_container);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:64: error: package R does not exist
toolbar = (Toolbar) findViewById(R.id.toolbar);
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:70: error: package R does not exist
channelNames = getResources().getStringArray(R.array.channel_names);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:71: error: package R does not exist
channelId = getResources().getStringArray(R.array.channel_id);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:72: error: package R does not exist
videoTypes = getResources().getStringArray(R.array.video_types);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:87: error: package R does not exist
.withHeaderBackground(R.drawable.main_icon)
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:127: error: package R does not exist
.replace(R.id.fragment_container, fragment)
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:133: error: package R does not exist
overridePendingTransition(R.anim.open_next, R.anim.close_main);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:133: error: package R does not exist
overridePendingTransition(R.anim.open_next, R.anim.close_main);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:100: error: package R does not exist
.withName(getString(R.string.about))
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:156: error: package R does not exist
.replace(R.id.fragment_container, fragment)
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:163: error: package R does not exist
Fragment f = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:186: error: package R does not exist
String.format(getString(R.string.error_player),
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:208: error: package R does not exist
getMenuInflater().inflate(R.menu.activity_home, menu);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:215: error: package R does not exist
case R.id.menuAbout:
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:219: error: package R does not exist
overridePendingTransition(R.anim.open_next, R.anim.close_main);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:219: error: package R does not exist
overridePendingTransition(R.anim.open_next, R.anim.close_main);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:278: error: package R does not exist
(FragmentVideo) getFragmentManager().findFragmentById(R.id.video_fragment_container);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:78: error: package R does not exist
View view = inflater.inflate(R.layout.fragment_video_list, container, false);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:86: error: package R does not exist
view.findViewById(R.id.ultimate_recycler_view);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:87: error: package R does not exist
mLblNoResult = (TextView) view.findViewById(R.id.lblNoResult);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:88: error: package R does not exist
mLytRetry = (LinearLayout) view.findViewById(R.id.lytRetry);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:89: error: package R does not exist
mPrgLoading = (CircleProgressBar) view.findViewById(R.id.prgLoading);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:90: error: package R does not exist
AppCompatButton btnRetry = (AppCompatButton) view.findViewById(R.id.raisedRetry);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:93: error: package R does not exist
mPrgLoading.setColorSchemeResources(R.color.accent_color);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:112: error: package R does not exist
.inflate(R.layout.progressbar, null));
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:120: error: package R does not exist
.inflate(R.layout.progressbar, null));
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:189: error: package R does not exist
Utils.PARAM_KEY_YOUTUBE + getResources().getString(R.string.youtube_apikey) + "&" +
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:198: error: package R does not exist
Utils.PARAM_KEY_YOUTUBE + getResources().getString(R.string.youtube_apikey) + "&" +
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:315: error: package R does not exist
msgSnackBar = getResources().getString(R.string.no_internet_connection);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:317: error: package R does not exist
msgSnackBar = getResources().getString(R.string.response_error);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:350: error: package R does not exist
Utils.PARAM_KEY_YOUTUBE+getResources().getString(R.string.youtube_apikey)+"&"+
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:426: error: package R does not exist
msgSnackBar = getResources().getString(R.string.no_internet_connection);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:428: error: package R does not exist
msgSnackBar = getResources().getString(R.string.response_error);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:502: error: package R does not exist
case R.id.raisedRetry:
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentVideo.java:21: error: package R does not exist
initialize(getResources().getString(R.string.youtube_apikey), this);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:45: error: package R does not exist
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_video_list, parent, false);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:74: error: package R does not exist
R.mipmap.empty_photo, R.mipmap.empty_photo));
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:74: error: package R does not exist
R.mipmap.empty_photo, R.mipmap.empty_photo));
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:109: error: package R does not exist
txtTitle = (TextView) v.findViewById(R.id.txtTitle);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:110: error: package R does not exist
txtDuration = (TextView) v.findViewById(R.id.txtDuration);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:111: error: package R does not exist
txtPublished = (TextView) v.findViewById(R.id.txtPublishedAt);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:112: error: package R does not exist
imgThumbnail = (ImageView) v.findViewById(R.id.imgThumbnail);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:141: error: package R does not exist
timeAgo = dim + " " + ctx.getResources().getString(R.string.date_util_unit_minutes);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:143: error: package R does not exist
timeAgo = ctx.getResources().getString(R.string.date_util_prefix_about) + " " +
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:144: error: package R does not exist
ctx.getResources().getString(R.string.date_util_unit_hour);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:147: error: package R does not exist
timeAgo = ctx.getResources().getString(R.string.date_util_prefix_about) + " " +
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:149: error: package R does not exist
ctx.getResources().getString(R.string.date_util_unit_hour);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:151: error: package R does not exist
timeAgo = ctx.getResources().getString(R.string.date_util_prefix_about) + " " +
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:153: error: package R does not exist
ctx.getResources().getString(R.string.date_util_unit_hours);
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:158: error: package R does not exist
ctx.getResources().getString(R.string.date_util_unit_day);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:161: error: package R does not exist
ctx.getResources().getString(R.string.date_util_unit_days);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:164: error: package R does not exist
ctx.getResources().getString(R.string.date_util_unit_daya);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:167: error: package R does not exist
ctx.getResources().getString(R.string.date_util_unit_day);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:169: error: package R does not exist
timeAgo = ctx.getResources().getString(R.string.date_util_prefix_about) + " "+
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:170: error: package R does not exist
ctx.getResources().getString(R.string.date_util_unit_month);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:178: error: package R does not exist
timeAgo = ctx.getResources().getString(R.string.date_util_prefix_about) + " "+
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:182: error: package R does not exist
ctx.getResources().getString(R.string.date_util_unit_year);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:184: error: package R does not exist
timeAgo = ctx.getResources().getString(R.string.date_util_prefix_almost) + " 2 " +
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:185: error: package R does not exist
ctx.getResources().getString(R.string.date_util_unit_years);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:187: error: package R does not exist
timeAgo = ctx.getResources().getString(R.string.date_util_prefix_about) + " " +
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:189: error: package R does not exist
ctx.getResources().getString(R.string.date_util_unit_years);
^
/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:192: error: package R does not exist
return timeAgo + " " + ctx.getResources().getString(R.string.date_util_suffix);
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
97 errors
:app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.564 secs
Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources,
according to this output
Note: Some input files use or override a deprecated API.
API that I used in this project was deprecated, but how I can know which one and how I can fix it?
Also I have such warning
Invalid VCS root mapping
The directory /Users/admin is registered as a Git root, but no Git repositories were found there.
but I think it is doesn't impact directly to R class error.
What am I doing wrong?
Once it happened to me as well. The reason was I copied a java file from another project and pasted that in project. Then I started getting the error 'R does not exist'. The reason behind that was I copied a java file from different project and in that project R file is available in different package. What I did I just imported the R file that belongs to my package. And done. You need to make sure if you are copying any activity file in you project please update R's package according to your project package.
NOTE: One more thing you can do you just go to the area where all the imports statements available(on the top your java file). Remove import statement for R's file and then import that again. It will import your package R file.Hope it will help you out.
Late to the party, but this just happened to me in Android Studio 3.0 after adding a new activity to my project. Turns out the activity had the wrong package name (d'oh! Not sure if that was my fault or AS's). Correcting the package name at the top of the java file and moving it to the correct folder solved the problem.
I was in execution of a java program in order to extract XML files.I received this Run Time Exception when i ran my java program. Please Suggest
During Compilation
This is the compile time error which i got
" GenerateInvoice.java:57: package com.ociweb.xml does not exist
import com.ociweb.xml.Version;
^
GenerateInvoice.java:58: package com.ociweb.xml does not exist
import com.ociweb.xml.WAX;
^
GenerateInvoice.java:69: package com.ociweb.xml does not exist
import com.ociweb.xml.WAX;
^
GenerateInvoice.java:73: cannot resolve symbol
symbol : class WAX
location: class GenerateInvoice
WAX waxDoc = null;
^
GenerateInvoice.java:453: cannot resolve symbol
symbol : class WAX
location: class GenerateInvoice
waxDoc = new WAX("/u01/Output/report/gen_xml/work/" + DIR_NAME + "/" + file_name + "_invoice.xml", Version.V1_0);
^
GenerateInvoice.java:453: cannot resolve symbol
symbol : variable Version
location: class GenerateInvoice
waxDoc = new WAX("/u01/Output/report/gen_xml/work/" + DIR_NAME + "/" + file_name + "_invoice.xml", Version.V1_0);
"
Then i added a package "wax14_1.0.4.jar". After Running :
Exception in thread "main" java.lang.NoSuchMethodError:
java.util.regex.Pattern.quote(Ljava/lang/String;)Ljava/lang/String;
at com.ociweb.xml.XMLUtil.<clinit>(XMLUtil.java:83)
at com.ociweb.xml.ElementMetadata.buildQualifiedName(ElementMetadata.java:155)
at com.ociweb.xml.ElementMetadata.<init>(ElementMetadata.java:136)
at com.ociweb.xml.WAX.start(WAX.java:829)
at com.ociweb.xml.WAX.start(WAX.java:816)
at com.ociweb.xml.WAX.start(WAX.java:803)
According to the doc (http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html), that method is available since 1.5. Check if you are running an environment < 1.5. If that's the case, you must use Retroweaver, as explained in the project main page (https://code.google.com/p/waxy/).