Android autolink autostart error

I am having problems with the autoLink = "phone" parameter in a TextView. My user interface:

<?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/TableLayout1" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/personPhone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:autoLink="phone" android:text="test" /> </TableLayout> 

When I switch to graphical layout (in ADT), I get the following error: An exception that occurred during rendering: com / android / i18n / phonenumbers / PhoneNumberUtil The exception information is logged in the window> View view> Error log The following classes could not be found: - TextView (change in android.widget.TextView, fix build path, edit XML)

Error in the log:

 java.lang.NoClassDefFoundError: com/android/i18n/phonenumbers/PhoneNumberUtil at android.text.util.Linkify.gatherTelLinks(Linkify.java:451) at android.text.util.Linkify.addLinks(Linkify.java:230) at android.widget.TextView.setText(TextView.java:3700) at android.widget.TextView.setText(TextView.java:3622) at android.widget.TextView.<init>(TextView.java:1259) at android.widget.TextView.<init>(TextView.java:607) at sun.reflect.GeneratedConstructorAccessor16.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at android.view.LayoutInflater.createView(LayoutInflater.java:594) at android.view.BridgeInflater.onCreateView(BridgeInflater.java:86) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:131) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:727) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:373) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:385) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:440) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1545) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1302) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:1059) at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegatePageChange(LayoutEditorDelegate.java:686) at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:360) at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:292) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774) at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3028) at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1749) at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:278) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584) at org.eclipse.equinox.launcher.Main.run(Main.java:1438) at org.eclipse.equinox.launcher.Main.main(Main.java:1414) 

If i remove

 android:autoLink="phone" 

the error disappears.

Also, if I change the "phone" to "email", there will be no errors, but "everyone" causes the same error.

+4
source share
2 answers

I have the same behavior when I use API level 18 to render a view. This will not affect your program. As a workaround, you can change the "version of the API to use when rendering in Eclipse" to 16 rather than 18 when working with layouts that include autostart. There is a button above the graphical representation with a robot icon and a number that you can use to change this.

This error also occurs in Android Studio and is tracked in the Android tracker at http://code.google.com/p/android/issues/detail?id=59497 .

+22
source

I have a simple solution. you can use tools: namespace to override Android namespace, for example, you can use the following code example

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:autoLink="all" tools:autoLink="none" /> 

You only need the xmlns tools: tools = "http://schemas.android.com/tools" and : autoLink = "none" This will only be used for previewing, you cannot detect the attributes at runtime

You can also use this namespace for other attributes, for example:

 tools:text="Some text that visible only on preview" 
0
source

Source: https://habr.com/ru/post/1499372/


All Articles